在我的开发者控制台的Crashes& ANR选项卡中获取此错误代码。 这是完整的StackTrace:
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.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:983)
at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:256)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:224)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:164)
at com.xxxx.xxx.Database.open(Database.java:239)
at com.xxxx.xxx.Infodata.isItemFavorite(Infodata.java:1051)
at com.xxxx.xxx.Infodata.onCreateOptionsMenu(Infodata.java:602)
at android.support.v4.app.Fragment.performCreateOptionsMenu(Fragment.java:1582)
at android.support.v4.app.FragmentManagerImpl.dispatchCreateOptionsMenu(FragmentManager.java:1956)
at android.support.v4.app.FragmentActivity.onCreatePanelMenu(FragmentActivity.java:225)
at android.support.v7.app.ActionBarActivity.superOnCreatePanelMenu(ActionBarActivity.java:232)
at android.support.v7.app.ActionBarActivityDelegateICS.onCreatePanelMenu(ActionBarActivityDelegateICS.java:147)
at android.support.v7.app.ActionBarActivity.onCreatePanelMenu(ActionBarActivity.java:199)
at android.support.v7.app.ActionBarActivityDelegateICS$WindowCallbackWrapper.onCreatePanelMenu(ActionBarActivityDelegateICS.java:285)
at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:489)
at com.android.internal.policy.impl.PhoneWindow.doInvalidatePanelMenu(PhoneWindow.java:853)
at com.android.internal.policy.impl.PhoneWindow$1.run(PhoneWindow.java:273)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5081)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:781)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
我的课程中指出的错误代码是:
at com.xxxx.xxx.Database.open(Database.java:239)
String BDFAV_NAME = "db_fav";
int BDFAV_VERSION = 1;
DBHelper = new DbHelper(Context, BDFAV_NAME, BDFAV_VERSION);
BDFav = DBHelper.getWritableDatabase(); //this is the line 239
at com.xxxx.xxx.Infodata.isItemFavorite(Infodata.java:1051)
boolean isItemFavorite() {
bDFav.open(); // line 1051
......
}
at com.xxxx.xxx.Infodata.onCreateOptionsMenu(Infodata.java:602)
isItemFavorite()
和bDFav
位于onCreateView()
activityContext = getActivity().getApplicationContext();
bDFav = new Database(activityContext, true);
似乎无法理解为什么我收到此错误。有什么想法吗?