java - Android SQLite database is locked when pressing power button (screen off) -


i'm getting large amount of information server , loading them in sqlite database (about 4000 rows). i'm using following code insert info:

string db_path = "/data/data/com.example.app.myapplication/databases/";             string db_name = "mydb.sqlite";             sqlitedatabase sqdb = sqlitedatabase.opendatabase(db_path + db_name, null, sqlitedatabase.no_localized_collators);             try {                 //getting info                 sqdb.begintransaction();                 string[] all_elements = all.split("_");                 (int j = 0; j < all_elements .length; j++) {                     if (all_elements [j].length() >= 1) {                         m.setlength(0);                         m.append("insert .....the query");                         m.append(");");                         sqdb.execsql(m.tostring().replaceall("\n", "").replaceall("\r", "").replaceall("\t", ""));                          changeprogressmessage("adding element " + string.valueof(j + 1) + "/" + string.valueof(all_elements .length));                     }                 }                 sqdb.settransactionsuccessful();                 sqdb.endtransaction();             }             catch (exception ex)             {                 log.d("error",ex.tostring());                 sqdb.settransactionsuccessful();                 sqdb.endtransaction();              } 

the point is, when inserting info, if press power button or screen off, app crashes , error saying database locked. please note i'm using connection sqlite database i'm closing before using second one.

 db.opendatabase();                  string[] array_elements = array.split("_");                 (int = 0; < array_elements .length; i++) {                     string details = "";                     if (!array_elements [i].isempty() && !array_elements [i].equals("")) {                          mbuilder.setlength(0);                         mbuilder.append(array_elements [i] + ",'" + helper.getdatetime() + "'");                          db.insertelements(mbuilder.tostring(), "element");                         changeprogressmessage("element" + string.valueof(i + 1) + "/" + string.valueof(array_elements .length) + " inserted");                       }                   }                 db.close(); 

any please ?

sorry guys bad, accessing database in on resume method, when turning off screen turning on, on resume method called database method inside explains crash.


Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -