Skip to content Skip to sidebar Skip to footer

Random Exception Android.database.sqlite.sqliteexception: Unable To Open Database File

My app uses a uncaught exception handler that sends the stack trace to me when the app crashes. Often I get this report from random users. I cannot replicate it, the opening of th

Solution 1:

i got the same error after upgrading my android firmware. the database was created by the old firmware and therefore couldn't be opened by the new firmware. users could solve this error by uninstall and reinstall your app.

Solution 2:

One of the possible scenarios when this could happen -- is when you access your database file from several threads and when the file is locked by one of the threads while you're trying to open it for modifications from another thread.

Solution 3:

there can be if your app opens database from multiple threads at same time that can be the reason for this exception.

please try synchronized method to open database.synchronized method will not allow database to be open from multiple threads at same time. put below code in your dbHelper

privatesynchronized SQLiteDatabase getWritableDB(){
        //get your database and return it from this method.
}

and call these method when your are getting db. Hope it will help.

Solution 4:

@yuku

This kind of issue i have faced, I have solved this issue like that way.

  1. We need check whether Old database is same as New Database, If something changed into new Database that time we need delete Old database and install new database OR alter the table as per new Database

  2. Second option is easy just uninstall your old application and than install new application

Hope this will work for you..!!!

Solution 5:

For any database application , I create the sqlite database first with Sqlite Manager addon of Firefox and take it in /res/raw folder. Then in my code, I check if the database exists in /data/data for this app. If not , I copy the db file to that directory with my code.

For your situation, it's hard to determine the exact reason without seeing how you have created your database and how are you using it.There can be several reason for the issue of getting this exception. Some issues already mentioned by others. I want to mention a one. Can you try opening the database like this

SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.NO_LOCALIZED_COLLATORS);  

Probably, I could try better to help if you show your code snippets. Well, my methods are described here , you can take a look if that helps.

Populating SQLite Database

Post a Comment for "Random Exception Android.database.sqlite.sqliteexception: Unable To Open Database File"