Optimized transactions in database access

git-svn-id: https://forja.rediris.es/svn/cusl6-swadroid/trunk@220 5bc14d19-1e4b-4ba2-aa50-860af135f48c
This commit is contained in:
Juan Miguel Boyero Corral 2011-11-22 22:30:08 +00:00
parent cd9e854289
commit cb697399a8
4 changed files with 10 additions and 14 deletions

View File

@ -836,7 +836,7 @@ public class DataBaseHelper {
public void upgradeDB(Context context) throws XmlPullParserException, IOException {
//cleanTables();
//initializeDB();
//compactDB();
compactDB();
/*db.getDB().execSQL("CREATE TEMPORARY TABLE __"
+ Global.DB_TABLE_NOTIFICATIONS

View File

@ -185,6 +185,8 @@ public class Notifications extends Module {
sendRequest(Notification.class, false);
if (result != null) {
dbHelper.beginTransaction();
//Stores notifications data returned by webservice response
Vector<?> res = (Vector<?>) result;
SoapObject soap = (SoapObject) res.get(1);
@ -213,6 +215,8 @@ public class Notifications extends Module {
//Clear old notifications to control database size
dbHelper.clearOldNotifications(SIZE_LIMIT);
dbHelper.endTransaction();
}
}

View File

@ -260,9 +260,7 @@ public class TestsConfigDownload extends Module {
protected void postConnect() {
if(numQuestions == 0) {
Toast.makeText(this, R.string.noQuestionsAvailableTestsDownloadMsg, Toast.LENGTH_LONG).show();
}
if(!isPluggable) {
} else if(!isPluggable) {
Toast.makeText(this, R.string.noQuestionsPluggableTestsDownloadMsg, Toast.LENGTH_LONG).show();
}

View File

@ -151,13 +151,10 @@ public class TestsQuestionsDownload extends Module {
Log.d(TAG, "UPDATED: " + q.toString());
}
}
dbHelper.endTransaction();
Log.i(TAG, "Retrieved " + listSize + " questions");
//Read answers info from webservice response
dbHelper.beginTransaction();
//Read answers info from webservice response
listSize = answersListObject.getPropertyCount();
for (int i = 0; i < listSize; i++) {
SoapObject pii = (SoapObject)answersListObject.getProperty(i);
@ -184,12 +181,9 @@ public class TestsQuestionsDownload extends Module {
}
}
dbHelper.endTransaction();
Log.i(TAG, "Retrieved " + listSize + " answers");
//Read relationships between questions and tags from webservice response
dbHelper.beginTransaction();
//Read relationships between questions and tags from webservice response
listSize = questionTagsListObject.getPropertyCount();
for (int i = 0; i < listSize; i++) {
SoapObject pii = (SoapObject)questionTagsListObject.getProperty(i);
@ -220,7 +214,6 @@ public class TestsQuestionsDownload extends Module {
}
}
dbHelper.endTransaction();
Log.i(TAG, "Retrieved " + listSize + " relationships between questions and tags");
//Update last time test was updated
@ -228,6 +221,7 @@ public class TestsQuestionsDownload extends Module {
Test testConfig = oldTestConfigDB;
testConfig.setEditTime(System.currentTimeMillis() / 1000L);
dbHelper.updateTestConfig(oldTestConfigDB, testConfig);
dbHelper.endTransaction();
}
//Request finalized without errors