Hi I am developing android app. It has 9 tables currently I have created one instance to open db and using the same throughout the whole project. I don't know whether this is causing my UI to freeze. should I open and close the DB every time when I do DB operation or what I am doing is correct?
\** to fetch records**\
public synchronized SQLiteDatabase readDatabase() {
if(mOpenCounter == 1) {//to open the database only one time
// Reading
mDatabase = mDatabaseHelper.getReadableDatabase();
}
return mDatabase;
}
\** to open db **\
public synchronized SQLiteDatabase openDatabase()throws SQLException {
mOpenCounter+=1;
if(mOpenCounter == 1) {//to open the database only one tim
mDatabase = mDatabaseHelper.getWritableDatabase();
}
return mDatabase;
}
UPDATE Hi From 2 days I am working on this.When I go through several links on google I found we need to do db operations on separate thread Can some one give me example of how to do this.Its not like one query I have 9 tables each table has around 8 queries.Is each query should be run in seperate thread?
My code structure is like I have created a separate class for each table query for example for Table A,TableAqueries all queries regarding this table comes here.Please give me a solution to run the db operations in separate thread. Please help me
Please help me