android out of cell service

53 Views Asked by At

I am developing an app that will likely be used in places that are out of cell or wifi service. Currently, the app connects to a remote MYSQL database; however, I am thinking about utilizing a 'local' sqlite DB when I detect I am out of cell or wifi range (then sync with the remote DB later once back in range).

How would you recommend going about detecting current cell/wifi state programatically? In other words, when I am in cell / wifi range, continue to use the remote DB. If I detect I'm out of range, use the local DB - then later, on rechecking the state of connectivity, sycn it up.

The question I'm asking relates to determining the state of internet connectivity.

1

There are 1 best solutions below

0
On BEST ANSWER

You should be able to monitor your connectivity by following these docs

http://developer.android.com/training/monitoring-device-state/connectivity-monitoring.html

Check this every time you want to perform an action to determine if you should use the local DB or make a remote call.