This question would be a follow up from the one asked Content Resolver vs Cursor Loader Where the answer clearly states how to insert records into a sqlite Db using a Content Resolver . My question is the following :
- Can i use a loader(Normal Loader) to implement this functionality ?
eg :
public Loader<Cursor> onCreateLoader(int id, Bundle bundle) {
switch (id) {
case AppConstants.LOADER_ADD_FAV_PHONE_NUM:
ContentValues values = new ContentValues();
values.put(DBHelper.TM_DB_COLUMN_PHONE_NUMBER,
directionOrder);
values.put(TransitMeDBHelper.TM_DB_COLUMN_NAME_ID, selectionArgs[0]);
Uri insertFavStop =getContentResolver().insert(TransitMeContentProvider.CONTENT_URI_INSERT_FAV_PHONE,
values);
break;
}
return null;
}
Would this run the functionality in the Main UI thread or a worker Thread . I understand that i would not receive callbacks for this as the content resolver will return a URI instead of the cursor containing data .
I tried running this code but it behaves kind of wierd .. Duplicate inserts are recorded and its not consistient , Could someone show me to some right resource which uses a Loader to do Insert operations ( I have seen many examples with query examples and it works like a charm :) )
Thank you for your time .