Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Android: Large database crashes app

Installing a large database (6MB, in my test case) causes the application to crash. The same application works fine with the exact same database if it contains fewer rows (a 293KB database works fine.)

Steps to reproduce:

  1. Copy large database to Resources folder
  2. In code, install the database
  3. Open a recordset (only need to select a few rows)
  4. Attempting to check rows.isValidRow() causes an immediate crash
— asked March 19th 2010 by Mark Burggraf
  • android
  • bug
  • crash
  • database
  • sqlite
0 Comments

8 Answers

  • Accepted Answer

    This is weird, but name your source database as .mp3 that insures that it gets packed into the app. When you use the install method it'll then copy over (e.g. mydb.mp3) android only handles resources up to 1MB except for a few special extensions.

    — answered March 19th 2010 by Don Thorp
    permalink
    0 Comments
  • Look in the Trace level log for the exception.

    — answered March 19th 2010 by Don Thorp
    permalink
    0 Comments
  • The error that comes up is "no such table", which leads me to believe there's a problem when installing the database. (As the exact same code works with a smaller copy of the same database.) Perhaps it's having a problem copying large files?

    [TRACE] E/TiDB ( 217): (kroll$2) [124,2675] Error executing sql: no such table: MYTABLE: , while compiling: SELECT fld1,fld2,fld3 FROM MYTABLE where fld1 = 1 order by fld2
    [TRACE] E/TiDB ( 217): android.database.sqlite.SQLiteException: no such table: MYTABLE: , while compiling: SELECT fld1,fld2,fld3 FROM MYTABLE where fld1 = 1 order by fld2
    [TRACE] E/TiDB ( 217): at android.database.sqlite.SQLiteProgram.native_compile(Native Method)
    [TRACE] E/TiDB ( 217): at android.database.sqlite.SQLiteProgram.compile(SQLiteProgram.java:110)
    [TRACE] E/TiDB ( 217): at android.database.sqlite.SQLiteProgram.(SQLiteProgram.java:59)
    [TRACE] E/TiDB ( 217): at android.database.sqlite.SQLiteQuery.(SQLiteQuery.java:49)
    [TRACE] E/TiDB ( 217): at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:49)
    [TRACE] E/TiDB ( 217): at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1118)

    — answered March 19th 2010 by Mark Burggraf
    permalink
    0 Comments
  • Then what would be the syntax in the db.install command?

    Would this work:

    db.install('mydb.mp3','mydb');

    — answered March 19th 2010 by Mark Burggraf
    permalink
    0 Comments
  • Then what would be the syntax in the db.install command?

    Would this work:

    db.install('mydb.mp3','mydb');

    — answered March 19th 2010 by Mark Burggraf
    permalink
    0 Comments
  • This appears to work, but is this something that can be fixed in future builds of Titanium?

    — answered March 19th 2010 by Mark Burggraf
    permalink
    0 Comments
  • Mark, I've tried to register db as a file to copy regardless and the Android tooling just seemed to ignore it.

    — answered March 19th 2010 by Don Thorp
    permalink
    0 Comments
  • > I've tried to register db as a file to copy regardless and the Android tooling just seemed to ignore it.

    So what does that mean?

    — answered March 19th 2010 by Mark Burggraf
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.