Here's what I wanna do. I want to download the data from our Website's Database and store it to sqlite. We are doing this to have an offline version of the app. This is just a View so there's no update and delete methods.
I'm trying to insert json to Android Sqlite with few data and it is successful. But here come's a problem when I try to do it with longer data. I need to insert around 19,000 rows to the table. I use to ProgressDialog that runs on UiThread to give user an idea of progress
The class is doing well but when inserting that much data takes a lot of time and android gives an error. Sometime it gives an error "Taking too long to respond: Wait or Cancel". Sometimes, like this...
Unfortunately, the App had stopped
But the App did not stop actually because in the logs I can see that it is still inserting to the table. Android gives that error, i think it did not recognize that I'm still inserting, or I don't know what seems to be the problem. The insert in the logs stops when I click the OK in the dialog box of error.
ui.setting.UserSettingsActivity: insertEquipmentProfile: 16494
ui.setting.UserSettingsActivity: insertEquipmentProfile: 16495
ui.setting.UserSettingsActivity: insertEquipmentProfile: 16496
Then after that, it logs this kinds of error:
E/SQLiteLog: (5) database is locked
E/SQLiteDatabase: Failed to open database '/data/data/http://ift.tt/1RznN7o'.
android.database.sqlite.SQLiteDatabaseLockedException: database is locked (code 5): , while compiling: PRAGMA journal_mode
what should I do? I'm not sure if this log matters but I'll add this, its like timeout but for I don't know.
W/ActivityManager: Activity pause timeout for ActivityRecord{f2e77e1 u0 ui.setting.UserSettingsActivity t762 f}
I did also tried to add Transactions in my database helper methods but it did not help.
database.beginTransaction();
database.setTransactionSuccessful();
database.endTransaction();
Is there a way to insert too many rows to the table? I'm not sure what data I'll provide to let me explain my problem but I'm looking for ways not crash the app while inserting too many data because my code works fine in inserting 4000 rows.
Aucun commentaire:
Enregistrer un commentaire