Skip to content

Commit c14c1c5

Browse files
committed
Uses official setForeignKeyConstraintsEnabled() for JB+
1 parent b8d4c14 commit c14c1c5

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/edu/mit/mobile/android/content/SimpleContentProvider.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import android.database.sqlite.SQLiteDatabase;
3535
import android.database.sqlite.SQLiteOpenHelper;
3636
import android.net.Uri;
37+
import android.os.Build;
3738
import android.util.Log;
3839
import edu.mit.mobile.android.content.column.DBColumn;
3940
import edu.mit.mobile.android.content.dbhelper.SearchDBHelper;
@@ -703,9 +704,22 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
703704
public void onOpen(SQLiteDatabase db) {
704705
super.onOpen(db);
705706

706-
if (AndroidVersions.SQLITE_SUPPORTS_FOREIGN_KEYS) {
707+
// starting with JB, use onConfigure()
708+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN
709+
&& AndroidVersions.SQLITE_SUPPORTS_FOREIGN_KEYS) {
707710
db.execSQL("PRAGMA foreign_keys = ON;");
708711
}
709712
}
713+
714+
@Override
715+
public void onConfigure(SQLiteDatabase db) {
716+
super.onConfigure(db);
717+
718+
// this check is still in place so that other the M2M classes will be feature-matched
719+
// with this variable's status.
720+
if (AndroidVersions.SQLITE_SUPPORTS_FOREIGN_KEYS) {
721+
db.setForeignKeyConstraintsEnabled(true);
722+
}
723+
}
710724
}
711725
}

test/project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99

1010
android.library.reference.1=..
1111
# Project target.
12-
target=android-16
12+
target=android-17

0 commit comments

Comments
 (0)