This paper illustrates the large data processing and simultaneous reading and writing methods of Android SQLite operation. Share to everyone for your reference, specific as follows:
1. Bulk Write
The use of things, the first cache data, and then batch write data, greatly improve the speed
288, direct inset into 7 seconds
8,640, batch writing takes 5-7 seconds
try {
this.myDataBase.beginTransaction ();//Manually set start transaction for
(int i = 0; i < objarr.length; i++) {
this.mydata Base.execsql (Sql[i]);
This.myDataBase.setTransactionSuccessful (); Set transaction success without setting automatically rollback uncommitted
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 to read, write more,
Getreadabledatabase is read (the bottom is to open the write format, then to read-only mode, if the system is low on memory, open read-only mode)
Curse cur, cur before doing the operation (e.g. Movetofirst () ... are just a pointer and do not operate on the database.
Getwritabledatabase for writing
The open mode of the two operation databases is mutually exclusive, and the underlying sync lock is added
More interested readers of Android-related content can view this site: "Android operation SQLite Database Skills Summary", "Android operation JSON format Data Skills summary", "Android Database Operation skills Summary", " The activity Operation skill summary of Android programming, the "Android file Operation skill Summary", "Android programming development SD Card Operation method Summary", "Android Development introduction and Advanced Course", "Android Resource Operation skill Summary", " Android View tips Summary and a summary of the use of Android controls
I hope this article will help you with the Android program.