I am trying to check if a sqlite database is empty using
public boolean chkDB(){
boolean chk = false;
Cursor mCursor = db.rawQuery(\"SELECT
You can query database with total row count. If it is > 0 then you can run your next code. Below function will return row value from database.
public BigDecimal getTotalRecordCount() {
SQLiteDatabase db = getReadableDatabase();
String sql = "select count(*) from " + DatabaseHelperTable.TABLE_NAME ;
Cursor cursor = db.rawQuery(sql, null);
try {
cursor.moveToFirst();
String sum = cursor.getString(0);
if (sum == null)
return new BigDecimal("0");
return new BigDecimal(sum);
} finally {
cursor.close();
}
}