0

i need your help. I have an android project. In this project i have to sync the db online and offline. For the offline db, i'm using sqlite and mysql for my online db. To retrieve data i'm using api. Now the question is, how can i update my offline when there's update in my online db ? I just want to update the updated data from my online db only not replacing all data in my sqlite. I'm using android studio. Thanks in advance

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Nicky Apriliani
  • 321
  • 4
  • 25
  • You have to use last modified date on both end. With that you get new updated data from the the server based on the last modified date. – Nas Mar 13 '17 at 05:22
  • You should check this - http://stackoverflow.com/questions/20580240/android-update-client-sqlite-database-using-gcm – Wasim K. Memon Mar 13 '17 at 05:26
  • you could also used realtime database that would update data once the device is online or the data is being altered example is the firebase realtime database – MuTiny Mar 13 '17 at 05:27
  • if i change only one line in my online db, can i update only one line to in my offline db? @Nas – Nicky Apriliani Mar 13 '17 at 05:30
  • @androidnoobdev – Nicky Apriliani Mar 13 '17 at 05:30
  • @NickyApriliani That depends upon your update script. if your online db can send only one record at the time of update db call you can do. so you have to make that script such powerful. – Wasim K. Memon Mar 13 '17 at 05:34
  • You should use `Sync Adapter` where you can find many training material online such as [this](https://developer.android.com/training/sync-adapters/index.html). – Mehran Zamani Mar 13 '17 at 05:43

0 Answers0