how to use a url to query a remote database for android?
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.
精彩评论