SQLite Android. unable to open database file

I have found many questions about this problem, but I cannot fix it. I have a sqlite db database in a resource folder:

assets/data/data/{package_name}/databases/mydb.db 

I can open the database and read the data before changing one table structure. I try to uninstall the application and install it again, but I get the same exception.

What can i do now?

Thanks in advance

EDIT

 // The Android default system path of your application database. private static String DB_PATH = "/data/data/{mypagackename}/databases/"; private static String DB_NAME = "mydb.db"; 

Open the database (before changing the structure of the table, adding some fields, it does not work)

 public void openDataBase() throws SQLException { // Open the database String myPath = DB_PATH + DB_NAME; myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); } 
+7
source share
2 answers

Check out this tutorial

He explains how to work with a preloaded database. Basically, you cannot use the database directly from the assets, you first need to copy it to the internal data warehouse and open it from there.

+11
source

Instead of hard-coded DB_PATH (no longer working in JB), I would recommend always using the Android built-in API method,

 mContext.getDatabasePath(DATABASE_NAME).getPath(); 
+3
source

All Articles