简体   繁体   中英

internet database to android app

I want the users of my app to view an internet database, download some records of it into the database that is built in the app (not online db) and also to be able to upload some records to the online database. I already have the database inside my app and my question is how can I make an online database that my android app could see, download from and upload to?

Android supports JDBC poorly - or let's be honest, not at all. Your best option is to create a Web server that wraps your database to a REST API. PHP is the most common language, while not the best, a lot of tutorials and snippets are available, so I would go with that. You'll have to wrap your database requests into HTTP requests and send it to the server.

For every query you'll plan on running, you'll have to create a PHP script that receives the HTTP parameters, builds the SQL query, and creates a structured XML or JSON response from the received data. This XML or JSON will than be sent to the Android client where you can parse it and obtain the data, do your syncing or such. I would suggest JSON, it's easier to read when debugging, consumes less bandwidth and has an easy to use parser in the Android API.

An easy lecture on PHP web service basics.

On using databases from PHP.

HTTP in Android.

JSON in Android.

Your online database should be on some server and you need to write a webservice to communicate your app to this online database(downloading and uploading purposes). your websrvice will also be hosted on some server. You then will be making webservice calls from your app to perform required modification to the online database.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM