1010import android .text .TextUtils ;
1111
1212import fr .free .nrw .commons .CommonsApplication ;
13- import fr .free .nrw .commons .data .DBOpenHelper ;
1413import timber .log .Timber ;
1514
1615public class ModificationsContentProvider extends ContentProvider {
@@ -33,10 +32,9 @@ public static Uri uriForId(int id) {
3332 return Uri .parse (BASE_URI .toString () + "/" + id );
3433 }
3534
36- private DBOpenHelper dbOpenHelper ;
35+
3736 @ Override
3837 public boolean onCreate () {
39- dbOpenHelper = CommonsApplication .getInstance ().getDBOpenHelper ();
4038 return false ;
4139 }
4240
@@ -54,7 +52,7 @@ public Cursor query(Uri uri, String[] projection, String selection, String[] sel
5452 throw new IllegalArgumentException ("Unknown URI" + uri );
5553 }
5654
57- SQLiteDatabase db = dbOpenHelper .getReadableDatabase ();
55+ SQLiteDatabase db = CommonsApplication . getInstance (). getDBOpenHelper () .getReadableDatabase ();
5856
5957 Cursor cursor = queryBuilder .query (db , projection , selection , selectionArgs , null , null , sortOrder );
6058 cursor .setNotificationUri (getContext ().getContentResolver (), uri );
@@ -70,7 +68,7 @@ public String getType(Uri uri) {
7068 @ Override
7169 public Uri insert (Uri uri , ContentValues contentValues ) {
7270 int uriType = uriMatcher .match (uri );
73- SQLiteDatabase sqlDB = dbOpenHelper .getWritableDatabase ();
71+ SQLiteDatabase sqlDB = CommonsApplication . getInstance (). getDBOpenHelper () .getWritableDatabase ();
7472 long id = 0 ;
7573 switch (uriType ) {
7674 case MODIFICATIONS :
@@ -86,7 +84,7 @@ public Uri insert(Uri uri, ContentValues contentValues) {
8684 @ Override
8785 public int delete (Uri uri , String s , String [] strings ) {
8886 int uriType = uriMatcher .match (uri );
89- SQLiteDatabase sqlDB = dbOpenHelper .getWritableDatabase ();
87+ SQLiteDatabase sqlDB = CommonsApplication . getInstance (). getDBOpenHelper () .getWritableDatabase ();
9088 switch (uriType ) {
9189 case MODIFICATIONS_ID :
9290 String id = uri .getLastPathSegment ();
@@ -104,7 +102,7 @@ public int delete(Uri uri, String s, String[] strings) {
104102 public int bulkInsert (Uri uri , ContentValues [] values ) {
105103 Timber .d ("Hello, bulk insert! (ModificationsContentProvider)" );
106104 int uriType = uriMatcher .match (uri );
107- SQLiteDatabase sqlDB = dbOpenHelper .getWritableDatabase ();
105+ SQLiteDatabase sqlDB = CommonsApplication . getInstance (). getDBOpenHelper () .getWritableDatabase ();
108106 sqlDB .beginTransaction ();
109107 switch (uriType ) {
110108 case MODIFICATIONS :
@@ -132,7 +130,7 @@ public int update(Uri uri, ContentValues contentValues, String selection, String
132130 In here, the only concat created argument is for id. It is cast to an int, and will error out otherwise.
133131 */
134132 int uriType = uriMatcher .match (uri );
135- SQLiteDatabase sqlDB = dbOpenHelper .getWritableDatabase ();
133+ SQLiteDatabase sqlDB = CommonsApplication . getInstance (). getDBOpenHelper () .getWritableDatabase ();
136134 int rowsUpdated = 0 ;
137135 switch (uriType ) {
138136 case MODIFICATIONS :
0 commit comments