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:
- Copy large database to Resources folder
- In code, install the database
- Open a recordset (only need to select a few rows)
- Attempting to check rows.isValidRow() causes an immediate crash
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.
-
Look in the Trace level log for the exception.
-
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) -
Then what would be the syntax in the db.install command?
Would this work:
db.install('mydb.mp3','mydb');
-
Then what would be the syntax in the db.install command?
Would this work:
db.install('mydb.mp3','mydb');
-
This appears to work, but is this something that can be fixed in future builds of Titanium?
-
Mark, I've tried to register db as a file to copy regardless and the Android tooling just seemed to ignore it.
-
> 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?