Reputation: 21
For the android application I am making I want to keep the database locally on the device and sync it with the server periodically (say every one hour).
There is going to be a database on the website related to this app made using phpmyadmin.
I am new to android. Please suggest how to go about this. Thanks.
How do I use REST to do this? I don't understand
Upvotes: 2
Views: 424
Reputation: 1606
If each device will need to sync with the database hourly, and not knowing the amount of data that will be transmitted in a sync, would it make more sense to just leave the data on the server and have the application access it on a need-be basis?
Update Check out Calling a REST web service from Android, which is a good example on how to do this. Without knowing how your web service is set up, it's hard to give specifics.
If you are brand-new to android, you're going to spend a lot time in the reference. It also probably would help to get a beginner's book, of which there are many.
Upvotes: 0
Reputation: 16110
You will need to learn how to create a database on the android phone. for this start looking into content providers and databases. a good example is the android NotePad Tutorial and sample code provided on android developers Notepad Tutorial.
Next for the web database you just create it through phpMyAdmin which is simple but to make it available for sync you need to make and deploy a webService: Rest, SOAP etc... with xml or json communication for example.
after you do that you need to learn how to make Http Post and Get calls, Parse your data and insert into your phone database. (make sure you do this in a seperate thread and not the UI - by async task or Thread).
for the periodic sync you need to make a background service which will be started by an alarm periodically. for this see broadcast receivers and alarm manager class.
Upvotes: 1