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
I am already using as given in that link for a long time..
It works.. Checkout your DB again the table created or not ?
I prefer to install SQLite Manager plugin in firefox for sqlite database operation.. after completing all process as mentioned in the same link..
Checkout http://www.devx.com/wireless/Article/40842/1954.
It contains all database operations.
it might also just be file permissions - the error message is misleading. first you need to find out the user id of the app (this is assuming you have root access):
$ adb shell grep <packagename> /data/system/packages.xml
output should look like:
<package name="com.fsck.k9" codePath="/data/app/com.fsck.k9-1.apk"
nativeLibraryPath="/data/data/com.fsck.k9/lib"
flags="0" ft="1306ecac340" it="1306ecac9d2" ut="1306ecac9d2"
version="14001" userId="10002">
userId here is 10002.
then fix permissions:
$ adb shell chown -R 10002:10002 /data/data/<packagename>
In my case, I have discovered that this error will happen if I leave an open transaction
left.
In other words: If you forget to commit
or rollback
a transaction, in the next time you enter in your application, this error raises up.
精彩评论