I’m using the well documented code to insert data in my sqlite database
ContentValues cv = new ContentValues();
cv.put("timestamp", timestamp);
cv.put (..., ...);
db.insert("datatable", "id", cv);
This lasts usually about 50ms, but afters some inserts it lasts over 900 ms and goes back to 50ms. Because the db inserts are done in the main thread, the long inserts (over 900ms) blocks my UI.
Has someone an idea to avoid such long inserts?
You shouldn’t be doing those operation on the main UI thread. Spawn a new thread or use an
AsyncTask.