Permalink
Browse files

Fix a lot of small errors reported via the Android Error reporting sy…

…stem
  • Loading branch information...
1 parent 8213f29 commit abffd055832341129eca376c4d385322098227e3 @matburt committed May 3, 2011
View
2 src/com/matburt/mobileorg/MobileOrgApplication.java
@@ -38,7 +38,7 @@ public void pushSelection(int selectedNode)
public void popSelection()
{
- if (nodeSelection.size() > 0)
+ if (this.nodeSelection != null && this.nodeSelection.size() > 0)
this.nodeSelection.remove(nodeSelection.size()-1);
}
View
13 src/com/matburt/mobileorg/MobileOrgDatabase.java
@@ -6,6 +6,7 @@
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDiskIOException;
+import android.database.DatabaseUtils;
import android.os.Environment;
import android.preference.PreferenceManager;
import android.util.Log;
@@ -42,7 +43,13 @@ else if (storageMode.equals("sdcard")) {
morgDir.mkdir();
}
File morgFile = new File(morgDir, "mobileorg.db");
- this.appdb = SQLiteDatabase.openOrCreateDatabase(morgFile, null);
+ try {
+ this.appdb = SQLiteDatabase.openOrCreateDatabase(morgFile, null);
+ }
+ catch (Exception e) {
+ ErrorReporter.displayError(this.appcontext,
+ r.getString(R.string.error_opening_database));
+ }
Log.d(LT, "Setting database path to " + morgFile.getAbsolutePath());
}
else {
@@ -68,7 +75,7 @@ public void close() {
public void wrapExecSQL(String sqlText) {
try {
- this.appdb.execSQL(sqlText);
+ this.appdb.execSQL(DatabaseUtils.sqlEscapeString(sqlText));
}
catch (SQLiteDiskIOException e) {
ErrorReporter.displayError(this.appcontext,
@@ -83,7 +90,7 @@ public void wrapExecSQL(String sqlText) {
public Cursor wrapRawQuery(String sqlText) {
Cursor result = null;
try {
- result = this.appdb.rawQuery(sqlText, null);
+ result = this.appdb.rawQuery(DatabaseUtils.sqlEscapeString(sqlText), null);
}
catch (SQLiteDiskIOException e) {
ErrorReporter.displayError(this.appcontext,

0 comments on commit abffd05

Please sign in to comment.