am e2a281ca: Merge "Add additional Method that check whether a table is empty or not"
* commit 'e2a281ca85f17eaf6d47978c76d2cafb0fa81782': Add additional Method that check whether a table is empty or not
This commit is contained in:
@@ -791,6 +791,18 @@ public class DatabaseUtils {
|
|||||||
selectionArgs);
|
selectionArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query the table to check whether a table is empty or not
|
||||||
|
* @param db the database the table is in
|
||||||
|
* @param table the name of the table to query
|
||||||
|
* @return True if the table is empty
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static boolean queryIsEmpty(SQLiteDatabase db, String table) {
|
||||||
|
long isEmpty = longForQuery(db, "select exists(select 1 from " + table + ")", null);
|
||||||
|
return isEmpty == 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility method to run the query on the db and return the value in the
|
* Utility method to run the query on the db and return the value in the
|
||||||
* first column of the first row.
|
* first column of the first row.
|
||||||
|
|||||||
Reference in New Issue
Block a user