3

I have a form to submit data to server when the device is online, but when the device is offline I want to store the data to local device storage and automatically send the data to server when the device is online.

Does anyone have an example or documentation of how to do this? I haven't started build the app yet, so I have no code to share.

Antonio
  • 729
  • 3
  • 11
  • 31
  • For this you can check this Answer similar to your problem http://stackoverflow.com/questions/26360034/how-to-send-data-to-server-from-android-when-no-internet-is-available – shalini May 04 '17 at 05:06

2 Answers2

0

you should check the connectivity , if user wasn't connected to the internet you should save the data on your local storage then you should listen for the Connectivity Status after that you can send the data with a Background Service or other methods like Alarm Manager for checking periodic Connectivity status ;

Koorosh Ghorbani
  • 475
  • 3
  • 10
0

you can use service for that i worked on same issue i made one sync service class which is extending intent service. so what you have to do you have to store all data in local db with one "upload status" and call on on pause in every activity call service class in this service class you have to get all data based on upload status which you have to upload . and post data to server via asynktast or any other.and after successfully upload change the status again .when net come on resume will call and hit to service class and process will go you can use notification builder for display process

android_jain
  • 752
  • 7
  • 19