No such table android_metadata, what's the problem?

I am copying a pre-existing database to /data/data/packagename/databases using code learned from using-your-own-sqlite-database-in-android-applications

After copying, I recieve the following log message on opening the database:

No such table android_metadata

Do I need to create a table named android_metadata? And what the values do i need insert into this database table

Thanks very much


Actually, with a bit more reading, I have discovered that I need to use the SQLiteDatabase.NO_LOCALIZED_COLLATORS flag when calling SQLiteDatabase.openDatabase() - this no longer causes the problem.


Use

SQLiteDatabase.openDatabase(dbPath, null,SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.CREATE_IF_NECESSARY);

or

SQLiteDatabase.openDatabase(dbPath, null,SQLiteDatabase.OPEN_READWRITE);

It seems that for some reason android requires every database to have a table called android_metadata that includes at least one locale. The reigndesign blog you mentioned tells you how to create the table and prefill it with a locale.

Check if your database contains this table and if the table has some content.


When you copy database from your assets directory for example, then you must have android_metadata table created in it already. This table should have two columns:

_id = an integer value
locale = en