I am trying to check if a sqlite database is empty using
public boolean chkDB(){
boolean chk = false;
Cursor mCursor = db.rawQuery(\"SELECT
Set up a query-method (either in your ContentProvider directly) or in another class using your ContentResolver with a projection for one column (ID should do the trick). Then see if the cursor contains anything or not.
I did this outside the ContentProvider in a task class:
//Is database empty?
public static boolean isDbEmpty(Context context) {
ContentResolver contentResolver = context.getContentResolver();
String[] projection = new String[] {#_ID#};
Cursor csr = checkResolver.query(#CONTENT_URI#, projection, null,
null, null);
if (csr != null && csr.moveToFirst()) {
csr.close();
return false;
} else {
return true;
}
}