0

Getting an error when trying to read a database in android studio, the application crashes as soon as I try and launch my search activity. I want the search activity to read the database and put the data into a list view. can anyone help? First error below is;

01-01 06:46:36.070 16496-16496/com.example.dean.databasecopy E/SQLiteLog: (14) cannot open file at line 30241 of [00bb9c9ce4]
01-01 06:46:36.070 16496-16496/com.example.dean.databasecopy E/SQLiteLog: (14) os_unix.c:30241: (2)     open(/data/data/com.example.dean.databasecopy/databases/productsains.db) - 
01-01 06:46:36.080 16496-16496/com.example.dean.databasecopy E/SQLiteDatabase: Failed to open database '/data/data/com.example.dean.databasecopy/databases/productsains.db'.
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:279)
                                                                               at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:218)
                                                                               at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:464)
                                                                               at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:186)
                                                                               at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:178)
                                                                               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.SQLiteDatabase.openDatabase(SQLiteDatabase.java:669)
                                                                               at com.example.dean.databasecopy.DataBaseManager.checkDataBase(DataBaseManager.java:135)
                                                                               at com.example.dean.databasecopy.DataBaseManager.createDataBase(DataBaseManager.java:96)
                                                                               at com.example.dean.databasecopy.DataBaseManager.<init>(DataBaseManager.java:51)
                                                                               at com.example.dean.databasecopy.DataBaseManager.instance(DataBaseManager.java:62)
                                                                               at com.example.dean.databasecopy.Search.onCreate(Search.java:29)
                                                                               at android.app.Activity.performCreate(Activity.java:5206)
                                                                               at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
                                                                               at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074)
                                                                               at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
                                                                               at android.app.ActivityThread.access$700(ActivityThread.java:140)
                                                                               at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
                                                                               at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                               at android.os.Looper.loop(Looper.java:137)
                                                                               at android.app.ActivityThread.main(ActivityThread.java:4921)
                                                                               at java.lang.reflect.Method.invokeNative(Native Method)
                                                                               at java.lang.reflect.Method.invoke(Method.java:511)
                                                                               at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
                                                                               at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
                                                                               at dalvik.system.NativeStart.main(Native Method)

Second error is;

01-01 06:46:36.090 16496-16496/com.example.dean.databasecopy E/AndroidRuntime: FATAL EXCEPTION: main
                                                                           java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.dean.databasecopy/com.example.dean.databasecopy.Search}: java.lang.NullPointerException
                                                                               at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110)
                                                                               at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
                                                                               at android.app.ActivityThread.access$700(ActivityThread.java:140)
                                                                               at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
                                                                               at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                               at android.os.Looper.loop(Looper.java:137)
                                                                               at android.app.ActivityThread.main(ActivityThread.java:4921)
                                                                               at java.lang.reflect.Method.invokeNative(Native Method)
                                                                               at java.lang.reflect.Method.invoke(Method.java:511)
                                                                               at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
                                                                               at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
                                                                               at dalvik.system.NativeStart.main(Native Method)
                                                                            Caused by: java.lang.NullPointerException
                                                                               at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:224)
                                                                               at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:188)
                                                                               at com.example.dean.databasecopy.DataBaseManager.createDataBase(DataBaseManager.java:108)
                                                                               at com.example.dean.databasecopy.DataBaseManager.<init>(DataBaseManager.java:51)
                                                                               at com.example.dean.databasecopy.DataBaseManager.instance(DataBaseManager.java:62)
                                                                               at com.example.dean.databasecopy.Search.onCreate(Search.java:29)
                                                                               at android.app.Activity.performCreate(Activity.java:5206)
                                                                               at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
                                                                               at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074)
                                                                               at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135) 
                                                                               at android.app.ActivityThread.access$700(ActivityThread.java:140) 
                                                                               at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237) 
                                                                               at android.os.Handler.dispatchMessage(Handler.java:99) 
                                                                               at android.os.Looper.loop(Looper.java:137) 
                                                                               at android.app.ActivityThread.main(ActivityThread.java:4921) 
                                                                               at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                               at java.lang.reflect.Method.invoke(Method.java:511)
  • Well, apparently you cannot open the database, this may be due to your application not having sufficient permissions or due to the database file not existing in my experience. If you can check for both of this cases you'll probably find your problem – Max Rasguido Apr 14 '16 at 18:54
  • I have the database file in my assets folder so I'm not sure why it's not able to open it. Any ideas? – Dean Swain Apr 14 '16 at 19:25

0 Answers0