Joe Richard Joe Richard - 24 days ago 8
Android Question

Table count in SQLite

I copied existing SQLite database from assets to databases folder. When I tried to retrieve data from one of table(gloss) it is giving an error:


android.database.sqlite.SQLiteException: no such table: gloss: , while
compiling: SELECT DISTINCT id, fk, lang, value FROM gloss WHERE value
like '%a%'


I want to make sure that all tables are copied to new db inside 'data/data/package/databases/'
How to get count of tables in SQLite db?

Answer

Why are you moving it from /assets? To count tables you should use this query:

SELECT count(*) FROM sqlite_master 
WHERE type = 'table' AND name != 'android_metadata' AND name != 'sqlite_sequence';

Edit**

It seems that my implementation was wrong. Use the query with the other answer.

Comments