I have database heavy operations happening, which adds around 10,000 records to my Database. Since this could take a very long time, it would be better to use transactions.
db.startTransaction();
....
do write operations.
....
db.setTransactionSuccessful();
db.endTransaction();
Now, I have some read operations inside the transactions, and since the inserts are not committed until endTransaction, those records are not fetched. I have heard about something called Transaction Isolation Levels, which enables us to read dirty (uncommitted) records as well. Any idea how to do this?
I found that by default you will be able to read records which are yet to be committed. Though this fails if you are using
SQliteOpenHelper. This is becauseSQliteOpenHelpergives 2 separate handled (read& write) and uncommitted writes won’t be available for read from the other handle.So, if you want to read uncommited records, use
SQLiteDatabaseclass.