summaryrefslogtreecommitdiffstats
path: root/core/java/android/database
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@android.com>2013-05-28 19:55:25 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2013-05-28 19:55:26 +0000
commite2a281ca85f17eaf6d47978c76d2cafb0fa81782 (patch)
tree015b7f2c477d497ac9746233b2bb15515f672381 /core/java/android/database
parent7f3ff133c19ed50dd245e025a44e1de7bcc3d38a (diff)
parentac4daee248b4bb0cb658c83437e4a9d93c6dce2d (diff)
downloadframeworks_base-e2a281ca85f17eaf6d47978c76d2cafb0fa81782.zip
frameworks_base-e2a281ca85f17eaf6d47978c76d2cafb0fa81782.tar.gz
frameworks_base-e2a281ca85f17eaf6d47978c76d2cafb0fa81782.tar.bz2
Merge "Add additional Method that check whether a table is empty or not"
Diffstat (limited to 'core/java/android/database')
-rw-r--r--core/java/android/database/DatabaseUtils.java12
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.
*/