Database not being copied from assets folder to device

后端 未结 2 1164
长情又很酷
长情又很酷 2021-01-05 19:15

I have a .db file in my assets folder. I\'ve copied it to the data/data//databases/ folder in the emulator and its working fine.

相关标签:
2条回答
  • 2021-01-05 19:46

    Got the answer... :)

    From here..

    http://www.anddev.org/networking-database-problems-f29/missing-table-in-sqlite-with-specific-version-of-desire-hd-t50364.html

    it was the problem with version 2.3.6... it was working with other devices... just added three lines to solve the problem...

    boolean dbExist = checkDataBase();
            SQLiteDatabase db_Read = null;
            if (!dbExist) 
            {
                db_Read = this.getReadableDatabase(); 
                db_Read.close();
    
                try 
                {
                    copyDataBase();
                } 
                catch (IOException e) 
                {
                    Log.d("Error", e.toString());
                }
            }
    
    0 讨论(0)
  • 2021-01-05 20:10

    Just change the database file .db extension in the asset folder to .png or any other compressed format it will worke in 2.1, 2.2 and above devices

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