How can I sync my Android SQLite database with a database on a server using json?

限于喜欢 提交于 2020-01-01 19:55:35

问题


I have an Android app with a sqlite db. I want to sync the content of the database with one on a php server, using json. I have the login and address of the server, so I need just the way to start. How do I connect? Do I need to decide protocol, like http or https?

What is the first step?

I use this:

TelephonyManager tManager = (TelephonyManager)this.mCtx.getSystemService(Context.TELEPHONY_SERVICE);
    String uid = tManager.getDeviceId();

To get a unique identifier to be sent with the request.

If I have a url, is this a way to go:

DefaultHttpClient httpclient = new DefaultHttpClient();
        HttpPost httpost = new HttpPost(path);?

Any inputs or good tutorials that take if from the beginning?


回答1:


Here is an example using the Android SyncAdapter framework, designed for syncing remote sources to the device.



来源:https://stackoverflow.com/questions/6314977/how-can-i-sync-my-android-sqlite-database-with-a-database-on-a-server-using-json

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!