1. Batch write, use the way of things, first cache the data, then bulk write data, greatly improve the speed
288, direct inset into time 7 seconds
8,640, batch write time 5-7 seconds
[Java]View Plaincopy
- try {
- this.myDataBase.beginTransaction (); //Manually set the start transaction
- For (int i = 0; i < objarr.length; i++) {
- This.myDataBase.execSQL (Sql[i]);
- }
- this.myDataBase.setTransactionSuccessful (); //SET transaction successfully, do not set automatically rollback does not commit
- Iresult = true;
- return iresult;
- } catch (SQLException e) {
- E.printstacktrace ();
- LOG.E ("Log", E.getmessage ());
- return iresult;
- } finally {
- this.myDataBase.endTransaction (); //processing complete
- This.myDataBase.close ();
- }
2. Simultaneous reading and writing
SQLite allows 1 reads, writes more,
Getreadabledatabase to read (the underlying is to open the write format, and then to read-only mode, if the system is low on memory, then open for read-only mode)
Curse cur, cur before doing the operation (such as Movetofirst () ... ) is just a pointer and does not operate on the database.
Getwritabledatabase for writing
There is an exclusive relationship between the open modes of the two operations databases, and the underlying synchronization lock
Android SQLite, big Data processing, simultaneous reading and writing