I am not sure what is the problem and how to handle this.
I have an helper class
public class DBAdapter {
public DBAdapter(Context ctx) {
this.context = ctx;
DBHelper = DatabaseHelper.getInstance(ctx);
}
private static class DatabaseHelper extends SQLiteOpenHelper {
private static DatabaseHelper mInstance = null;
DatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
public static DatabaseHelper getInstance(Context ctx) {
if (mInstance == null) {
mInstance = new DatabaseHelper(ctx.getApplicationContext());
database = mInstance.getWritableDatabase();
}
context = ctx;
return mInstance;
}
}
public void beginTransaction() {
database.beginTransaction();
Utils.log("Sqlite=> Begin Transaction");
}
public void endTransaction() {
database.setTransactionSuccessful();
database.endTransaction();
}
public void rollbackTransaction() {
database.endTransaction();
}
}
In my app I have an AsyncTask which within doInBackground does something like this:
db.beginTransaction();
//do a lot of insert queries for 5 minutes
db.endTransaction(); //or rollback in case of error
Now the problem I am having is this: while the AsyncTask is running and I have the transaction running, any select query I made, using database.rawQuery fails to run. Debugging it, it seems that the rawQuery command is waiting for the current transaction to finish, to return the results.
How can I have both, the long running transaction and extra read olny queries in the same time?
Aucun commentaire:
Enregistrer un commentaire