Permalink
Browse files

Merge pull request #43 from hippiefahrzeug/master

suggested fix for issue #42 reported by @hipplefahrzeug fixed by @alvi on hardcoded version field of android sqlite wrapper.
  • Loading branch information...
2 parents 335af3c + 276426b commit f10ff1486b0b32c44a9c4b395ffde1d8aea79148 @ahmetb committed Jan 25, 2012
Showing with 23 additions and 1 deletion.
  1. +23 −1 src/org/orman/dbms/sqliteandroid/SQLiteAndroid.java
@@ -25,7 +25,7 @@
* @author ahmet alp balkan <ahmetalpbalkan at gmail.com>
*/
public class SQLiteAndroid extends SQLiteOpenHelper implements Database {
- private static final int SQLITE_VERSION = 33; //TODO read from somewhere else ASAP
+ private static final int SQLITE_VERSION = 33; // legacy support for deprecated constructor. instead, specify db version explicitly.
private DataTypeMapper typeMapper;
private QueryExecutionContainerImpl executer;
private SQLiteGrammar grammar;
@@ -34,8 +34,30 @@
private String databaseName;
private SQLiteDatabase db;
+ /**
+ * android sets the version of the DB when it is opened.
+ */
+ public SQLiteAndroid(Context context, String dbFilename, int version) {
+ super(context, dbFilename, null, version);
+ init(dbFilename);
+ }
+
+ /**
+ * constructor kept for legacy purposes: all DBs created before this patch
+ * will have version '33' and therefore need to specify a version equal or
+ * greater (in case of a schema upgrade).
+ *
+ * where is the db version stored? see:
+ * http://stackoverflow.com/questions/3707797/where-does-android-store-sqlite-database-version
+ *
+ * @deprecated use SQLiteAndroid(Context context, String dbFilename, int version) instead
+ */
public SQLiteAndroid(Context context, String dbFilename) {
super(context, dbFilename, null, SQLITE_VERSION);
+ init(dbFilename);
+ }
+
+ private void init(String dbFilename) {
SQLiteDatabase db = getWritableDatabase();
this.db = db;

0 comments on commit f10ff14

Please sign in to comment.