我的應用程序工作正常,到目前爲止,但在某些設備上即時得到一個錯誤(安卓4.1或4.3爲例)無法打開數據庫
android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
Caused by: android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:209)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:193)
at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177)
at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:804)
at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:789)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:694)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:235)
at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:188)
在類DBManager我有這樣的:
public class DBManager {
public DBHelper helper;
private SQLiteDatabase db;
private Cursor c;
public DBManager(Context context) {
helper = new DBHelper(context);
db = helper.getReadableDatabase();
// db = helper.getWritableDatabase();
}
而且在DBHelper這樣的:
public class DBHelper extends SQLiteOpenHelper {
private static final String DATABASE_NAME = Environment.getExternalStorageDirectory() + "/database/database.db3";
private static final int DATABASE_VERSION = 3;
public DBHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(CREATE_TABLE_SQL);
}
清單等,是確定,但我不明白爲什麼有些設備上SQLiteCantOpenData baseException來了。我希望有人能幫我解決這個問題? Thanx提前
你爲什麼不發佈任何代碼?你如何會得到幫助 – meda
檢查這http://stackoverflow.com/questions/17034511/android-database-sqlite-sqlitecantopendatabaseexception-unknown-error-code-14 – hehe
太快了:)現在我已經添加的代碼:) – Frank