How to send data to a server from Android if the Internet is not available

I have created a form application that sends data to my mysql server. Everything is fine, but I have a question: what should I use if my application has no internet. The user enters data and is sent if I have internet, but what if for 5 or 10 minutes I have no internet access and the user is still sending data. Am I losing this data or is there a way to save the data and when internet is activated, all saved data is transferred to my mysql server ... ??

I've heard about JSON Parser, but I don't know exactly how it works ...

+2


source to share


1 answer


Customize BroadcastReceiver

in your Android app

When your user submits some data and clicks the submit button, check the device's internet connection. If the internet is not available, save the data in the local database or general settings (if the data is small). Now that the internet is available, your broadcast receiver will be called and check the data in the local database. If there is one, it will have to send this data, as you already did.




  1. To test internet connection : How to check internet access on Android? InetAddress never expires
  2. To create a Broadcast Reciever to check network availability : Broadcast receiver to check internet connection in Android app
  3. To work with a database: Android SQLite example
  4. If you want to use sharedPreferences: how to use SharedPreferences in Android to store, retrieve and edit values
  5. To send data to server: Send POST data to Android



+17


source







All Articles