1

Hi I'm building an app in which data gets loaded on start of application in SQLite and after which user can use the application even if he is offline he can add more data or make changes to the existing data and all these changes should be reflected to SQL server when internet connection gets active again.

Skynet
  • 7,820
  • 5
  • 44
  • 80
user2197811
  • 121
  • 1
  • 8
  • What problems are you facing and where? Please add some code – AndyFaizan Feb 23 '14 at 12:57
  • You can use a BroadcastReceiver to get to know when internet is active and start a service with a return of START_STICKY and use this service to put an alarm and run your code of updation thereafter. Content Providers are also helpful. Also this might be very helpful: http://developer.android.com/training/sync-adapters/index.html – Skynet Feb 23 '14 at 13:02
  • sorry to say this but m new to development would be really helpful if u guys share some code – user2197811 Feb 23 '14 at 13:23
  • the data to be updated to server is from different tables – user2197811 Feb 23 '14 at 13:26
  • try http://developer.android.com/training/sync-adapters/creating-sync-adapter.html – playmaker420 Mar 26 '14 at 09:28

1 Answers1

1

We can divide your problem into 3 main components that you will need 1- SQLite database component and you will find this tutorial very helpful

2- Cloud server communication server and this should happen in a different thread than the UI Main thread so you can use IntentService or Sevice, So check

3- Also as you want to listen when the device is connected to update your application data so you can use a broadcast receiver to listen for Internet changes, so you can use:

Then when you're not connected you use the data saved in your database. Then when getting connected, you go updating your data to be used in offline mode.

Community
  • 1
  • 1
Ahmed Zayed
  • 2,165
  • 1
  • 20
  • 21