diff options
author | Jeff Brown <jeffbrown@android.com> | 2013-05-28 13:00:28 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-05-28 13:00:28 -0700 |
commit | dcb8d876581f9bf77e51c5539ef68993870264d8 (patch) | |
tree | 97ae32229594ea13713d3b12a73c05ce1e9a8c84 /core/java/android/database/DatabaseUtils.java | |
parent | 2ee100c0999e15d11ad36f387a22d9500eb14a6f (diff) | |
parent | 79df1e65455fdb69f07675cffae99dea06a5afb2 (diff) | |
download | frameworks_base-dcb8d876581f9bf77e51c5539ef68993870264d8.zip frameworks_base-dcb8d876581f9bf77e51c5539ef68993870264d8.tar.gz frameworks_base-dcb8d876581f9bf77e51c5539ef68993870264d8.tar.bz2 |
am 79df1e65: am e2a281ca: Merge "Add additional Method that check whether a table is empty or not"
* commit '79df1e65455fdb69f07675cffae99dea06a5afb2':
Add additional Method that check whether a table is empty or not
Diffstat (limited to 'core/java/android/database/DatabaseUtils.java')
-rw-r--r-- | core/java/android/database/DatabaseUtils.java | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/core/java/android/database/DatabaseUtils.java b/core/java/android/database/DatabaseUtils.java index 1fc1226..e2d9724 100644 --- a/core/java/android/database/DatabaseUtils.java +++ b/core/java/android/database/DatabaseUtils.java @@ -792,6 +792,18 @@ public class DatabaseUtils { } /** + * 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 * first column of the first row. */ |