SQLite returned an error code of 14
I have seen this error occur if you are using sharedUserId in your manifest. If you change the sharedUserId of an application and reinstall the application it does not have the required ownership to write to the SQLite database.
Why am I getting an sqlite3 error 14 (unable to open database) when calling step on an sqlite3_stmt?
It's likely SQLite is unable create/write to a required temporary file for the transaction. Check your temp location.
See sqlite3_temp_directory.
android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database still unable to fix issue
Issue: Most of the times SQLiteCantOpenDatabaseException occurs when you are access your sqlite database from multiple threads. Let say you have opened the database in one thread and trying to access the database in another will cause SQLiteCantOpenDatabaseException exception.
Solution: Make a singleton object of your SQLiteOpenHelper class and always use the same instance for multiple threads.
Sample:
DBHelper class:
public class DBHelper extends SQLiteOpenHelper {
private DBHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
public synchronized static DBHelper getInstance(Context context) {
if (dbHelper == null) {
dbHelper = new DBHelper(context);
}
return dbHelper;
}
@Override
public void onCreate(SQLiteDatabase sqLiteDatabase) {
//...
}
@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
//...
onCreate(sqLiteDatabase);
}
}
Usage:
private static SQLiteDatabase database;
DBHelper dbHelper = DBHelper.getInstance(context);
if (database == null) {
database = dbHelper.getWritableDatabase();
}
Note: Never close the SqliteDatabase instance yourself android system does it for you.
SQLite error code:14, 'unable to open database file'
Take a look at Technical Q&A 1809: New default journaling mode for Core Data SQLite stores in iOS 7 and OS X Mavericks
Your application may be moving or changing the WAL journal files or SQLite files, or may have made assumptions about the file structure that was valid for versions of Core Data that did not use WAL.
It's also possible that your SQLite database is being corrupted, and the error 14 is SQLite attempting to repair the file when Core Data opens it. This corruption can happen if the application was not shut down properly when a write was happening - and many other circumstances. Not shutting down properly is the most common case on Apple platforms though - for example, if Core Data is writing records and the OS kills the application because it's unresponsive. That can cause corruption.
Related Topics
How to Change Bitmap Image Color in Android
How to Get Multiple Icons to Launch Different Activities in One Application
How to Get the Google Username on Android
Run Code Only Once After an Application Is Installed on Android Device
Android: Display Image from Sd Card
Android Google Maps, How to Make Each Marker Infowindow Open Different Activity
Fragment Transaction Animation: Slide in and Slide Out
Asynctask and Error Handling on Android
Findclass from Any Thread in Android Jni
Getting a Photo from a Contact
Android: Tabhost Without Tabactivity
Android: How to Use Webcam in Emulator
Popupwindow $Badtokenexception: Unable to Add Window -- Token Null Is Not Valid
Customize Check Box Preference