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