how to send data to server from android when no internet is available

前端 未结 1 1982
没有蜡笔的小新
没有蜡笔的小新 2020-12-15 01:57

I\'ve made a form app that send data to my mysql server. All is good but I have a question: what should I use if my app doesn\'t have internet..the user enters the data and

相关标签:
1条回答
  • 2020-12-15 02:37

    Set up a BroadcastReceiver in your android application

    When your user submits some data and press submit then check for the internet connection of the device.If internet is not available then store the data in the local database or shared preferences(if data is small). Now when internet will be available,your broadcast receiver will be called and will check the data in the local database.If present ,it will have to send that data as you used to do already.


    1. For checking the internet connection : How to check internet access on Android? InetAddress never times out
    2. For creating Broadcast Reciever for checking availability of network : Broadcast receiver for checking internet connection in android app
    3. For dealing with database : Android SQLite Example
    4. If you wish to use sharedPreferences : How to use SharedPreferences in Android to store, fetch and edit values
    5. For sending data to server : Sending POST data in Android

    0 讨论(0)
提交回复
热议问题