开发者

how to use a url to query a remote database for android?

开发者 https://www.devze.com 2023-02-26 19:39 出处:网络
I have been stuck at this for hours now. I would like to use a URL to query a remote database in a开发者_如何学Gondroid. Can any1 give me an idea on how to do this? Thanks.I found a good website to an

I have been stuck at this for hours now. I would like to use a URL to query a remote database in a开发者_如何学Gondroid. Can any1 give me an idea on how to do this? Thanks.


I found a good website to answer this question: http://p-xr.com/android-tutorial-how-to-parseread-xml-data-into-android-listview/. Use HttpGet instead of HttpPost.
All thanks to Mark for helping me out with this.


There is no general way to tell this, as the URL itself depends on the database and the driver. Basically you need a jdbc driver for the database that you put into your project first. The docs will then give you the specific details.

For Postgres, this could look like

jdbc:postgresql://<host>5432/<dbname>

Having said that: usually it is no good idea to do remote jdbc calls (if you can't guarantee that the app will only be used in the local lan) and you should do some abstraction and e.g. send the data around via http requests that carry payloads encoded e.g. as json or xml.

0

精彩评论

暂无评论...
验证码 换一张
取 消