unable to copy database using SQLiteAssetHelper class

非 Y 不嫁゛ 提交于 2019-12-01 01:47:40

Missing databases/mydb.sqlite file (or .zip, .gz archive) in assets, or target folder not writable

Do you have the database file in your assets/databases folder?

no, in assets folder only

SQLiteAssetHelper expects to find the prepopulated database file in databases folder under assets.

Right click on your database file in the Package Explorer,

& click on the Properties.

inside the Resource Tab make sure the "Write" Permission is Checked for the "Owner" and "Read" Permission is Checked for all the "Users".

Make sure you have the db file under assets\databases folder in your app, in the main folder.

Also make sure you have specified the correct database name, so if your file name is data.db, your database name should be data.db.

public class MyHelperDatabase extends com.readystatesoftware.sqliteasset.SQLiteAssetHelper {

    private static final String DATABASE_NAME = "data.db";

Or if you are using Room:

public abstract class AppDatabase extends RoomDatabase {

    private static AppDatabase INSTANCE;

    @VisibleForTesting
    public static final String DATABASE_NAME = "data.db";
  1. Error: "Missing databases/EDMTQuiz2019.db file".
  2. Cause: my folder was not named properly... It was assets/database, Instead of assets/databases
  3. Solution: I solved mine by refactoring/renaming the folder "database" to "databases"
  4. Summary: the new right path is assets/databases (the .db file is in the database folder)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!