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 { public void upgradeDB(Context context) throws XmlPullParserException, IOException {
//cleanTables(); //cleanTables();
//initializeDB(); //initializeDB();
//compactDB(); compactDB();
/*db.getDB().execSQL("CREATE TEMPORARY TABLE __" /*db.getDB().execSQL("CREATE TEMPORARY TABLE __"
+ Global.DB_TABLE_NOTIFICATIONS + Global.DB_TABLE_NOTIFICATIONS

View File

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

View File

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

View File

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