How Can I Tell If Sqlite Database Is Empty Android?
Contents How Check Android Database Is Empty or Not? Set up a Query-Method (Either in Your Contentprovider Directly) or in Another Class Using Your...
Contents
How check Android database is empty or not?
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. You can query database with total row count. If it is > 0 then you can run your next code.
How do you check whether the database is empty or not?
SELECT COUNT(DISTINCT `TABLE_NAME`) AS anyAliasName FROM `INFORMATION_SCHEMA`. `COLUMNS` WHERE `table_schema` = ‘yourDatabaseName’; The above syntax returns 0 if the database has notable otherwise it returns the number of tables.