Synchronize to avoid exception

This commit is contained in:
Victor Shcherb 2014-07-30 23:42:49 +02:00
parent 714296c2fd
commit 96b06fbf81

View file

@ -129,7 +129,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
return res; return res;
} }
public boolean hasDataToSave() { public synchronized boolean hasDataToSave() {
try { try {
SQLiteDatabase db = getWritableDatabase(); SQLiteDatabase db = getWritableDatabase();
if (db != null) { if (db != null) {
@ -160,7 +160,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
/** /**
* @return warnings * @return warnings
*/ */
public List<String> saveDataToGpx() { public synchronized List<String> saveDataToGpx() {
List<String> warnings = new ArrayList<String>(); List<String> warnings = new ArrayList<String>();
File dir = ctx.getAppPath(IndexConstants.GPX_RECORDED_INDEX_DIR); File dir = ctx.getAppPath(IndexConstants.GPX_RECORDED_INDEX_DIR);
dir.mkdirs(); dir.mkdirs();
@ -376,7 +376,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
execWithClose(updatePointsScript, new Object[] { lat, lon, time, description }); execWithClose(updatePointsScript, new Object[] { lat, lon, time, description });
} }
private void execWithClose(String script, Object[] objects) { private synchronized void execWithClose(String script, Object[] objects) {
SQLiteDatabase db = getWritableDatabase(); SQLiteDatabase db = getWritableDatabase();
try { try {
if (db != null) { if (db != null) {