10
10
import android .text .TextUtils ;
11
11
12
12
import fr .free .nrw .commons .CommonsApplication ;
13
- import fr .free .nrw .commons .data .DBOpenHelper ;
14
13
import timber .log .Timber ;
15
14
16
15
public class ModificationsContentProvider extends ContentProvider {
@@ -33,10 +32,9 @@ public static Uri uriForId(int id) {
33
32
return Uri .parse (BASE_URI .toString () + "/" + id );
34
33
}
35
34
36
- private DBOpenHelper dbOpenHelper ;
35
+
37
36
@ Override
38
37
public boolean onCreate () {
39
- dbOpenHelper = CommonsApplication .getInstance ().getDBOpenHelper ();
40
38
return false ;
41
39
}
42
40
@@ -54,7 +52,7 @@ public Cursor query(Uri uri, String[] projection, String selection, String[] sel
54
52
throw new IllegalArgumentException ("Unknown URI" + uri );
55
53
}
56
54
57
- SQLiteDatabase db = dbOpenHelper .getReadableDatabase ();
55
+ SQLiteDatabase db = CommonsApplication . getInstance (). getDBOpenHelper () .getReadableDatabase ();
58
56
59
57
Cursor cursor = queryBuilder .query (db , projection , selection , selectionArgs , null , null , sortOrder );
60
58
cursor .setNotificationUri (getContext ().getContentResolver (), uri );
@@ -70,7 +68,7 @@ public String getType(Uri uri) {
70
68
@ Override
71
69
public Uri insert (Uri uri , ContentValues contentValues ) {
72
70
int uriType = uriMatcher .match (uri );
73
- SQLiteDatabase sqlDB = dbOpenHelper .getWritableDatabase ();
71
+ SQLiteDatabase sqlDB = CommonsApplication . getInstance (). getDBOpenHelper () .getWritableDatabase ();
74
72
long id = 0 ;
75
73
switch (uriType ) {
76
74
case MODIFICATIONS :
@@ -86,7 +84,7 @@ public Uri insert(Uri uri, ContentValues contentValues) {
86
84
@ Override
87
85
public int delete (Uri uri , String s , String [] strings ) {
88
86
int uriType = uriMatcher .match (uri );
89
- SQLiteDatabase sqlDB = dbOpenHelper .getWritableDatabase ();
87
+ SQLiteDatabase sqlDB = CommonsApplication . getInstance (). getDBOpenHelper () .getWritableDatabase ();
90
88
switch (uriType ) {
91
89
case MODIFICATIONS_ID :
92
90
String id = uri .getLastPathSegment ();
@@ -104,7 +102,7 @@ public int delete(Uri uri, String s, String[] strings) {
104
102
public int bulkInsert (Uri uri , ContentValues [] values ) {
105
103
Timber .d ("Hello, bulk insert! (ModificationsContentProvider)" );
106
104
int uriType = uriMatcher .match (uri );
107
- SQLiteDatabase sqlDB = dbOpenHelper .getWritableDatabase ();
105
+ SQLiteDatabase sqlDB = CommonsApplication . getInstance (). getDBOpenHelper () .getWritableDatabase ();
108
106
sqlDB .beginTransaction ();
109
107
switch (uriType ) {
110
108
case MODIFICATIONS :
@@ -132,7 +130,7 @@ public int update(Uri uri, ContentValues contentValues, String selection, String
132
130
In here, the only concat created argument is for id. It is cast to an int, and will error out otherwise.
133
131
*/
134
132
int uriType = uriMatcher .match (uri );
135
- SQLiteDatabase sqlDB = dbOpenHelper .getWritableDatabase ();
133
+ SQLiteDatabase sqlDB = CommonsApplication . getInstance (). getDBOpenHelper () .getWritableDatabase ();
136
134
int rowsUpdated = 0 ;
137
135
switch (uriType ) {
138
136
case MODIFICATIONS :
0 commit comments