check for db validity in has/pending offlinedata functions
This commit is contained in:
parent
65c9eeb773
commit
5c48526057
@ -123,6 +123,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasPendingOfflineData() {
|
private boolean hasPendingOfflineData() {
|
||||||
|
try {
|
||||||
Cursor c = getReadableDb().query("articles",
|
Cursor c = getReadableDb().query("articles",
|
||||||
new String[] { "COUNT(*)" }, "modified = 1", null, null, null,
|
new String[] { "COUNT(*)" }, "modified = 1", null, null, null,
|
||||||
null);
|
null);
|
||||||
@ -132,6 +133,9 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
|||||||
|
|
||||||
return modified > 0;
|
return modified > 0;
|
||||||
}
|
}
|
||||||
|
} catch (IllegalStateException e) {
|
||||||
|
// db is closed? ugh
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -141,6 +145,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasOfflineData() {
|
private boolean hasOfflineData() {
|
||||||
|
try {
|
||||||
Cursor c = getReadableDb().query("articles",
|
Cursor c = getReadableDb().query("articles",
|
||||||
new String[] { "COUNT(*)" }, null, null, null, null, null);
|
new String[] { "COUNT(*)" }, null, null, null, null, null);
|
||||||
if (c.moveToFirst()) {
|
if (c.moveToFirst()) {
|
||||||
@ -149,6 +154,9 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
|||||||
|
|
||||||
return modified > 0;
|
return modified > 0;
|
||||||
}
|
}
|
||||||
|
} catch (IllegalStateException e) {
|
||||||
|
// db is closed?
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user