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:
parent
cd9e854289
commit
cb697399a8
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -152,12 +152,9 @@ public class TestsQuestionsDownload extends Module {
|
|||
}
|
||||
}
|
||||
|
||||
dbHelper.endTransaction();
|
||||
Log.i(TAG, "Retrieved " + listSize + " questions");
|
||||
|
||||
//Read answers info from webservice response
|
||||
dbHelper.beginTransaction();
|
||||
|
||||
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();
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue
Block a user