From df8c1ff3f2e30e8b5be813e797ac1d675117ad05 Mon Sep 17 00:00:00 2001 From: swetasarat04 Date: Wed, 11 Oct 2023 18:12:21 -0400 Subject: [PATCH] Remove this use of "notifychange", it is deprecated. --- .../opentracks/data/CustomContentProvider.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/de/dennisguse/opentracks/data/CustomContentProvider.java b/src/main/java/de/dennisguse/opentracks/data/CustomContentProvider.java index e0922f538..a504fb11e 100644 --- a/src/main/java/de/dennisguse/opentracks/data/CustomContentProvider.java +++ b/src/main/java/de/dennisguse/opentracks/data/CustomContentProvider.java @@ -27,6 +27,7 @@ import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteQueryBuilder; import android.net.Uri; +import android.os.Build; import android.text.TextUtils; import android.util.Log; @@ -126,7 +127,9 @@ boolean onCreate(Context context) { try { db = databaseHelper.getWritableDatabase(); // Necessary to enable cascade deletion from Track to TrackPoints and Markers - db.setForeignKeyConstraintsEnabled(true); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + db.setForeignKeyConstraintsEnabled(true); + } } catch (SQLiteException e) { Log.e(TAG, "Unable to open database for writing.", e); } @@ -153,7 +156,7 @@ public int delete(@NonNull Uri url, String where, String[] selectionArgs) { } finally { db.endTransaction(); } - getContext().getContentResolver().notifyChange(url, null, false); + getContext().getContentResolver().notifyChange(url, null); int totalChanges = getTotalChanges() - totalChangesBefore; Log.i(TAG, "Deleted " + totalChanges + " total rows from database"); @@ -204,7 +207,7 @@ public Uri insert(@NonNull Uri url, ContentValues initialValues) { } finally { db.endTransaction(); } - getContext().getContentResolver().notifyChange(url, null, false); + getContext().getContentResolver().notifyChange(url, null); return result; } @@ -227,7 +230,7 @@ public int bulkInsert(@NonNull Uri url, @NonNull ContentValues[] valuesBulk) { } finally { db.endTransaction(); } - getContext().getContentResolver().notifyChange(url, null, false); + getContext().getContentResolver().notifyChange(url, null); return numInserted; } @@ -332,7 +335,7 @@ public int update(@NonNull Uri url, ContentValues values, String where, String[] } finally { db.endTransaction(); } - getContext().getContentResolver().notifyChange(url, null, false); + getContext().getContentResolver().notifyChange(url, null); return count; }