No such table android_metadata, what's the problem?

后端 未结 7 1802
后悔当初
后悔当初 2020-12-07 15:37

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

相关标签:
7条回答
  • 2020-12-07 16:09

    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>
    
    0 讨论(0)
  • 2020-12-07 16:14

    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.

    0 讨论(0)
  • 2020-12-07 16:15

    Use

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

    or

    SQLiteDatabase.openDatabase(dbPath, null,SQLiteDatabase.OPEN_READWRITE);
    
    0 讨论(0)
  • 2020-12-07 16:21

    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
    
    0 讨论(0)
  • 2020-12-07 16:22

    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.

    0 讨论(0)
  • 2020-12-07 16:23

    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.

    0 讨论(0)
提交回复
热议问题