java.lang.RuntimeException: Unable to create application uk.co.spiritquest.sfl11b1.ScifilondonApplication: android.database.sqlite.SQLiteException: unable to open database file

Appcelerator JIRA | Ketan Majmudar | 5 years ago
  1. 0

    h4. Problem Description When building to android I get regular occasional errors when building to the device which fails to initialise the app. h4. Actual Results Here is the DDMS error: {code} 04-05 15:36:30.609: E/TiApplication(32009): (main) [348,985] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to create application uk.co.spiritquest.sfl11b1.ScifilondonApplication: android.database.sqlite.SQLiteException: unable to open database file; Titanium 2.0.0,2012/03/30 10:33,b091bae 04-05 15:36:30.609: E/TiApplication(32009): java.lang.RuntimeException: Unable to create application uk.co.spiritquest.sfl11b1.ScifilondonApplication: android.database.sqlite.SQLiteException: unable to open database file 04-05 15:36:30.609: E/TiApplication(32009): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3812) 04-05 15:36:30.609: E/TiApplication(32009): at android.app.ActivityThread.access$2200(ActivityThread.java:132) 04-05 15:36:30.609: E/TiApplication(32009): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1082) 04-05 15:36:30.609: E/TiApplication(32009): at android.os.Handler.dispatchMessage(Handler.java:99) 04-05 15:36:30.609: E/TiApplication(32009): at android.os.Looper.loop(Looper.java:150) 04-05 15:36:30.609: E/TiApplication(32009): at android.app.ActivityThread.main(ActivityThread.java:4277) 04-05 15:36:30.609: E/TiApplication(32009): at java.lang.reflect.Method.invokeNative(Native Method) 04-05 15:36:30.609: E/TiApplication(32009): at java.lang.reflect.Method.invoke(Method.java:507) 04-05 15:36:30.609: E/TiApplication(32009): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 04-05 15:36:30.609: E/TiApplication(32009): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 04-05 15:36:30.609: E/TiApplication(32009): at dalvik.system.NativeStart.main(Native Method) 04-05 15:36:30.609: E/TiApplication(32009): Caused by: android.database.sqlite.SQLiteException: unable to open database file 04-05 15:36:30.609: E/TiApplication(32009): at android.database.sqlite.SQLiteDatabase.dbopen(Native Method) 04-05 15:36:30.609: E/TiApplication(32009): at android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1956) 04-05 15:36:30.609: E/TiApplication(32009): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:902) 04-05 15:36:30.609: E/TiApplication(32009): at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:208) 04-05 15:36:30.609: E/TiApplication(32009): at org.appcelerator.titanium.util.TiDatabaseHelper.getPlatformParam(TiDatabaseHelper.java:73) 04-05 15:36:30.609: E/TiApplication(32009): at org.appcelerator.titanium.util.TiPlatformHelper.initialize(TiPlatformHelper.java:69) 04-05 15:36:30.609: E/TiApplication(32009): at org.appcelerator.titanium.TiApplication.postAppInfo(TiApplication.java:349) 04-05 15:36:30.609: E/TiApplication(32009): at uk.co.spiritquest.sfl11b1.ScifilondonApplication.onCreate(ScifilondonApplication.java:34) 04-05 15:36:30.609: E/TiApplication(32009): at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:984) 04-05 15:36:30.609: E/TiApplication(32009): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3809) 04-05 15:36:30.609: E/TiApplication(32009): ... 10 more {code} h4. Expected results the DB working fine h4. Test Case 1. Create New mobile project 2. Add this code: {code} var win = Ti.UI.createWindow(); var l = Titanium.UI.createLabel({ text:'See Log for output', top:10, left:10, height:'auto', width:'auto' }); win.add(l); var b1 = Titanium.UI.createButton({ title:'DB in 2nd Context', width:200, height:40, top:40 }); win.add(b1); b1.addEventListener('click', function() { var win1 = Titanium.UI.createWindow({ url:'database_2.js', height:30, width:280, borderRadius:10, bottom:80, backgroundColor:'#333' }); var l1 = Titanium.UI.createLabel({ text:'2nd context test - see log.', color:'#fff', font:{fontSize:14}, width:'auto', height:'auto' }); win1.add(l1); win1.open(); }); var b2 = Titanium.UI.createButton({ title:'Pre-packaged DB', width:200, height:40, top:100 }); win.add(b2); b2.addEventListener('click', function() { var win2 = Titanium.UI.createWindow({ url:'database_3.js', height:30, width:280, borderRadius:10, bottom:140, backgroundColor:'#333' }); var l2= Titanium.UI.createLabel({ text:'Pre-packaged Db - see log.', color:'#fff', font:{fontSize:14}, width:'auto', height:'auto' }); win2.add(l2); win2.open(); }); var l3 = Titanium.UI.createLabel({ text:'unicode placeholder', width:300, height:40, top:190 }); win.add(l3); if (Ti.Platform.osname !== 'android') { win.add(l3); var b3 = Titanium.UI.createButton({ title:'Check DB FullPath', width:200, height:40, top:150 }); b3.addEventListener('click', function() { var path = db.file; alert("mysql.db fullpath : \n \nType :" + path +"\n\nFullPath: "+path.nativePath); }); win.add(b3); } var db = Titanium.Database.open('mydb'); db.execute('CREATE TABLE IF NOT EXISTS DATABASETEST (ID INTEGER, NAME TEXT)'); db.execute('DELETE FROM DATABASETEST'); db.execute('INSERT INTO DATABASETEST (ID, NAME ) VALUES(?,?)',1,'Name 1'); db.execute('INSERT INTO DATABASETEST (ID, NAME ) VALUES(?,?)',2,'Name 2'); db.execute('INSERT INTO DATABASETEST (ID, NAME ) VALUES(?,?)',3,'Name 3'); db.execute('INSERT INTO DATABASETEST (ID, NAME ) VALUES(?,?)',4,'Name 4'); db.execute('INSERT INTO DATABASETEST (ID, NAME ) VALUES(?,?)', 5, '\u2070 \u00B9 \u00B2 \u00B3 \u2074 \u2075 \u2076 \u2077 \u2078 \u2079'); var updateName = 'I was updated'; var updateId = 4; db.execute('UPDATE DATABASETEST SET NAME = ? WHERE ID = ?', updateName, updateId); db.execute('UPDATE DATABASETEST SET NAME = "I was updated too" WHERE ID = 2'); db.execute('DELETE FROM DATABASETEST WHERE ID = ?',1); Titanium.API.info('JUST INSERTED, rowsAffected = ' + db.rowsAffected); Titanium.API.info('JUST INSERTED, lastInsertRowId = ' + db.lastInsertRowId); var rows = db.execute('SELECT * FROM DATABASETEST'); Titanium.API.info('ROW COUNT = ' + rows.getRowCount()); Titanium.API.info('ROW COUNT = ' + rows.getRowCount()); Titanium.API.info('ROW COUNT = ' + rows.getRowCount()); while (rows.isValidRow()) { Titanium.API.info('ID: ' + rows.field(0) + ' NAME: ' + rows.fieldByName('name') + ' COLUMN NAME ' + rows.fieldName(0)); if (rows.field(0)==5) { l3.text = rows.fieldByName('name'); } rows.next(); } rows.close(); db.close(); // close db when you're done to save resources win.open(); {code} h4. Extra info Also the Studio Console failed to build prior to the above error: I will have to add that as a comment when i encounter it next.

    Appcelerator JIRA | 5 years ago | Ketan Majmudar
    java.lang.RuntimeException: Unable to create application uk.co.spiritquest.sfl11b1.ScifilondonApplication: android.database.sqlite.SQLiteException: unable to open database file
  2. 0

    h4. Problem Description When building to android I get regular occasional errors when building to the device which fails to initialise the app. h4. Actual Results Here is the DDMS error: {code} 04-05 15:36:30.609: E/TiApplication(32009): (main) [348,985] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to create application uk.co.spiritquest.sfl11b1.ScifilondonApplication: android.database.sqlite.SQLiteException: unable to open database file; Titanium 2.0.0,2012/03/30 10:33,b091bae 04-05 15:36:30.609: E/TiApplication(32009): java.lang.RuntimeException: Unable to create application uk.co.spiritquest.sfl11b1.ScifilondonApplication: android.database.sqlite.SQLiteException: unable to open database file 04-05 15:36:30.609: E/TiApplication(32009): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3812) 04-05 15:36:30.609: E/TiApplication(32009): at android.app.ActivityThread.access$2200(ActivityThread.java:132) 04-05 15:36:30.609: E/TiApplication(32009): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1082) 04-05 15:36:30.609: E/TiApplication(32009): at android.os.Handler.dispatchMessage(Handler.java:99) 04-05 15:36:30.609: E/TiApplication(32009): at android.os.Looper.loop(Looper.java:150) 04-05 15:36:30.609: E/TiApplication(32009): at android.app.ActivityThread.main(ActivityThread.java:4277) 04-05 15:36:30.609: E/TiApplication(32009): at java.lang.reflect.Method.invokeNative(Native Method) 04-05 15:36:30.609: E/TiApplication(32009): at java.lang.reflect.Method.invoke(Method.java:507) 04-05 15:36:30.609: E/TiApplication(32009): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 04-05 15:36:30.609: E/TiApplication(32009): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 04-05 15:36:30.609: E/TiApplication(32009): at dalvik.system.NativeStart.main(Native Method) 04-05 15:36:30.609: E/TiApplication(32009): Caused by: android.database.sqlite.SQLiteException: unable to open database file 04-05 15:36:30.609: E/TiApplication(32009): at android.database.sqlite.SQLiteDatabase.dbopen(Native Method) 04-05 15:36:30.609: E/TiApplication(32009): at android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1956) 04-05 15:36:30.609: E/TiApplication(32009): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:902) 04-05 15:36:30.609: E/TiApplication(32009): at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:208) 04-05 15:36:30.609: E/TiApplication(32009): at org.appcelerator.titanium.util.TiDatabaseHelper.getPlatformParam(TiDatabaseHelper.java:73) 04-05 15:36:30.609: E/TiApplication(32009): at org.appcelerator.titanium.util.TiPlatformHelper.initialize(TiPlatformHelper.java:69) 04-05 15:36:30.609: E/TiApplication(32009): at org.appcelerator.titanium.TiApplication.postAppInfo(TiApplication.java:349) 04-05 15:36:30.609: E/TiApplication(32009): at uk.co.spiritquest.sfl11b1.ScifilondonApplication.onCreate(ScifilondonApplication.java:34) 04-05 15:36:30.609: E/TiApplication(32009): at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:984) 04-05 15:36:30.609: E/TiApplication(32009): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3809) 04-05 15:36:30.609: E/TiApplication(32009): ... 10 more {code} h4. Expected results the DB working fine h4. Test Case 1. Create New mobile project 2. Add this code: {code} var win = Ti.UI.createWindow(); var l = Titanium.UI.createLabel({ text:'See Log for output', top:10, left:10, height:'auto', width:'auto' }); win.add(l); var b1 = Titanium.UI.createButton({ title:'DB in 2nd Context', width:200, height:40, top:40 }); win.add(b1); b1.addEventListener('click', function() { var win1 = Titanium.UI.createWindow({ url:'database_2.js', height:30, width:280, borderRadius:10, bottom:80, backgroundColor:'#333' }); var l1 = Titanium.UI.createLabel({ text:'2nd context test - see log.', color:'#fff', font:{fontSize:14}, width:'auto', height:'auto' }); win1.add(l1); win1.open(); }); var b2 = Titanium.UI.createButton({ title:'Pre-packaged DB', width:200, height:40, top:100 }); win.add(b2); b2.addEventListener('click', function() { var win2 = Titanium.UI.createWindow({ url:'database_3.js', height:30, width:280, borderRadius:10, bottom:140, backgroundColor:'#333' }); var l2= Titanium.UI.createLabel({ text:'Pre-packaged Db - see log.', color:'#fff', font:{fontSize:14}, width:'auto', height:'auto' }); win2.add(l2); win2.open(); }); var l3 = Titanium.UI.createLabel({ text:'unicode placeholder', width:300, height:40, top:190 }); win.add(l3); if (Ti.Platform.osname !== 'android') { win.add(l3); var b3 = Titanium.UI.createButton({ title:'Check DB FullPath', width:200, height:40, top:150 }); b3.addEventListener('click', function() { var path = db.file; alert("mysql.db fullpath : \n \nType :" + path +"\n\nFullPath: "+path.nativePath); }); win.add(b3); } var db = Titanium.Database.open('mydb'); db.execute('CREATE TABLE IF NOT EXISTS DATABASETEST (ID INTEGER, NAME TEXT)'); db.execute('DELETE FROM DATABASETEST'); db.execute('INSERT INTO DATABASETEST (ID, NAME ) VALUES(?,?)',1,'Name 1'); db.execute('INSERT INTO DATABASETEST (ID, NAME ) VALUES(?,?)',2,'Name 2'); db.execute('INSERT INTO DATABASETEST (ID, NAME ) VALUES(?,?)',3,'Name 3'); db.execute('INSERT INTO DATABASETEST (ID, NAME ) VALUES(?,?)',4,'Name 4'); db.execute('INSERT INTO DATABASETEST (ID, NAME ) VALUES(?,?)', 5, '\u2070 \u00B9 \u00B2 \u00B3 \u2074 \u2075 \u2076 \u2077 \u2078 \u2079'); var updateName = 'I was updated'; var updateId = 4; db.execute('UPDATE DATABASETEST SET NAME = ? WHERE ID = ?', updateName, updateId); db.execute('UPDATE DATABASETEST SET NAME = "I was updated too" WHERE ID = 2'); db.execute('DELETE FROM DATABASETEST WHERE ID = ?',1); Titanium.API.info('JUST INSERTED, rowsAffected = ' + db.rowsAffected); Titanium.API.info('JUST INSERTED, lastInsertRowId = ' + db.lastInsertRowId); var rows = db.execute('SELECT * FROM DATABASETEST'); Titanium.API.info('ROW COUNT = ' + rows.getRowCount()); Titanium.API.info('ROW COUNT = ' + rows.getRowCount()); Titanium.API.info('ROW COUNT = ' + rows.getRowCount()); while (rows.isValidRow()) { Titanium.API.info('ID: ' + rows.field(0) + ' NAME: ' + rows.fieldByName('name') + ' COLUMN NAME ' + rows.fieldName(0)); if (rows.field(0)==5) { l3.text = rows.fieldByName('name'); } rows.next(); } rows.close(); db.close(); // close db when you're done to save resources win.open(); {code} h4. Extra info Also the Studio Console failed to build prior to the above error: I will have to add that as a comment when i encounter it next.

    Appcelerator JIRA | 5 years ago | Ketan Majmudar
    java.lang.RuntimeException: Unable to create application uk.co.spiritquest.sfl11b1.ScifilondonApplication: android.database.sqlite.SQLiteException: unable to open database file
  3. 0

    Unable to open Titanium database » Community Questions & Answers » Appcelerator Developer Center

    appcelerator.com | 1 year ago
    android.database.sqlite.SQLiteException: unable to open database file
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Android SQLiteOpenHelper cannot open database file

    Stack Overflow | 6 years ago | AlexS
    android.database.sqlite.SQLiteException: unable to open database file
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. android.database.sqlite.SQLiteException

    unable to open database file

    at android.database.sqlite.SQLiteDatabase.dbopen()
  2. Android Platform
    SQLiteOpenHelper.getReadableDatabase
    1. android.database.sqlite.SQLiteDatabase.dbopen(Native Method)
    2. android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1956)
    3. android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:902)
    4. android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:208)
    4 frames
  3. org.appcelerator.titanium
    TiApplication.postAppInfo
    1. org.appcelerator.titanium.util.TiDatabaseHelper.getPlatformParam(TiDatabaseHelper.java:73)
    2. org.appcelerator.titanium.util.TiPlatformHelper.initialize(TiPlatformHelper.java:69)
    3. org.appcelerator.titanium.TiApplication.postAppInfo(TiApplication.java:349)
    3 frames
  4. uk.co.spiritquest
    ScifilondonApplication.onCreate
    1. uk.co.spiritquest.sfl11b1.ScifilondonApplication.onCreate(ScifilondonApplication.java:34)
    1 frame
  5. Android Platform
    ActivityThread.main
    1. android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:984)
    2. android.app.ActivityThread.handleBindApplication(ActivityThread.java:3809)
    3. android.app.ActivityThread.access$2200(ActivityThread.java:132)
    4. android.app.ActivityThread$H.handleMessage(ActivityThread.java:1082)
    5. android.os.Handler.dispatchMessage(Handler.java:99)
    6. android.os.Looper.loop(Looper.java:150)
    7. android.app.ActivityThread.main(ActivityThread.java:4277)
    7 frames
  6. Java RT
    Method.invoke
    1. java.lang.reflect.Method.invokeNative(Native Method)
    2. java.lang.reflect.Method.invoke(Method.java:507)
    2 frames
  7. Android
    ZygoteInit.main
    1. com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
    2. com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
    2 frames
  8. Android Platform
    NativeStart.main
    1. dalvik.system.NativeStart.main(Native Method)
    1 frame