Now I write this:
public boolean update(List<MyObject> list){ ContentValues cv = new ContentValues(); try { db.beginTransaction(); for(int i = 0; i < carlist.size(); i++) { cv.put(DataBaseConstants.ID, list.get(i).id); cv.put(DataBaseConstants.NUMBER, list.get(i).attributes.Number); cv.put(DataBaseConstants.MODEL, list.get(i).attributes.model); cv.put(DataBaseConstants.ER, list.get(i).attributes.er); cv.put(DataBaseConstants.IN, list.get(i).attributes.in); cv.put(DataBaseConstants.HIDDEN, list.get(i).attributes.Hidden); //еще несколько строк cv.put if (checkExistItem(db, DataBaseConstants.TABLE_NAME, DataBaseConstants.ID + "=?", new String[]{String.valueOf(list.get(i).id)})) { db.update(DataBaseConstants.TABLE_NAME, cv, DataBaseConstants.ID + "=?", new String[]{String.valueOf(list.get(i).id)}); } else { db.insert(DataBaseConstants.TABLE_NAME, null, cv); } updateType(db, list.get(i).id, list.get(i).ships.Type); updateState(db, list.get(i).id, list.get(i).ships.State); cv.clear(); } db.setTransactionSuccessful(); db.endTransaction(); Log.d("databaseSpeed","end "+new Date().toString()); return true; } catch (Exception e){ e.printStackTrace(); return false; } } public boolean checkExistItem(SQLiteDatabase db, String tableName, String where, String[] whereParams ){ Cursor mCursor = db.rawQuery("SELECT "+DataBaseConstants.ANDROID_TABLE_ID+" FROM " + tableName + " WHERE "+ where, whereParams); if (mCursor != null && mCursor.getCount() > 0){ mCursor.close(); return true; } else { mCursor.close(); return false; } } A list of more than 2000 entries, recorded a few seconds.
The update method has 100 entries. In these 100 entries, there are still nested sheets that go into the corresponding updateType and updateState methods . The sheet is transferred and the record takes a second or 2. In general, it takes a very long time. Is it possible to speed up?