Reputation: 1054
I have an Android application where the app should work offline. In the app when the records are been created during offline mode they are stored in the local database(sqlite), when the internet connection is available the records that were been created during offline should sync with parse.
How can I do it in Android?
Upvotes: 0
Views: 448
Reputation: 12953
Simple while run a background service to check whether your mobile is connected to internet or not,then get the data from your Local Database in one list and then Parse data into other list
public Collection nonOverLap(Collection coll1, Collection coll2) {
Collection result = union(coll1, coll2);
result.removeAll(intersect(coll1, coll2));
return result;
} // will return elements missing in parse
Then update the nonOverlap into parse Db :)
Upvotes: 1
Reputation: 37969
Check if device is connected to the Internet:
public static boolean isDeviceConnectedToTheInternet(Context ctx) {
NetworkInfo networkInfo =
((ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE))
.getActiveNetworkInfo();
return networkInfo != null && networkInfo.isConnected();
}
Then choose a scenario.
Upvotes: 0
Reputation: 1455
Look into firebase or couchdb or parse data objects
https://parse.com/docs/android/guide#objects
Upvotes: 0