It worked! I'm not sure what has changed. I use git and I have been looking at my commits and code for hours.
As indicated in the header, my uri match is no longer matched.
Below I have inserted the relevant parts of my content provider.
public class Provider extends ContentProvider { private static final String TAG = "Provider"; private static final String SCHEME = ContentResolver.SCHEME_CONTENT; private static final String AUTHORITY = "com.snot.bodyweightworkout.database.provider"; private static final String BASE_URI = SCHEME + AUTHORITY; public static final Uri URI_EXERCISES = Uri.parse(BASE_URI + "/exercise"); public static final Uri URI_PROGRAMS = Uri.parse(BASE_URI + "/program"); public static final Uri URI_PROGRAM_EXERCISES = Uri.parse(BASE_URI + "/program/#/exercise"); private static final int EXERCISE = 1; private static final int EXERCISES = 2; private static final int PROGRAM = 3; private static final int PROGRAMS = 4; private static final int PROGRAM_EXERCISES = 5; private static final UriMatcher sURIMatcher = new UriMatcher(UriMatcher.NO_MATCH); static { sURIMatcher.addURI(AUTHORITY, "/exercise", EXERCISES); sURIMatcher.addURI(AUTHORITY, "/exercise/#", EXERCISE); sURIMatcher.addURI(AUTHORITY, "/program", PROGRAMS); sURIMatcher.addURI(AUTHORITY, "/program/#", PROGRAM); sURIMatcher.addURI(AUTHORITY, "/program/#/exercise", PROGRAM_EXERCISES); }
...
And then the part in which the actual match should be performed.
@Override public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { Log.v(TAG, "URI: " + uri); Cursor result = null; int match = sURIMatcher.match(uri); switch(match) { case PROGRAMS: result = DatabaseHandler .getInstance(getContext()) .getReadableDatabase() .query(Program.TABLE_NAME, Program.FIELDS, null, null, null, null, null, null); result.setNotificationUri(getContext().getContentResolver(), URI_PROGRAMS); break; case PROGRAM: final long pid = Long.parseLong(uri.getLastPathSegment()); result = DatabaseHandler .getInstance(getContext()) .getReadableDatabase() .query(Program.TABLE_NAME, Program.FIELDS, Program.COL_ID + " IS ?", new String[] { String.valueOf(pid) }, null, null, null, null); result.setNotificationUri(getContext().getContentResolver(), URI_PROGRAMS); break; ... default: throw new UnsupportedOperationException("Unmatched(" + match + ") URI: " + uri.toString());
I am trying to execute a query using the cursor loader as follows:
getLoaderManager().initLoader(0, null, new LoaderManager.LoaderCallbacks<Cursor>() { @Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { return new CursorLoader(getActivity(), Provider.URI_PROGRAMS, Program.FIELDS, null, null, null); }
The default is hit by default. No coincidence made, I ended up with FC and the next line in my journal.
E/AndroidRuntime( 1979): Caused by: java.lang.UnsupportedOperationException: Unmatched(-1) URI: content:
I played this role for hours, and I really need fresh eyes to make a peak on it. Therefore, if any soul can look at him, I will be very grateful to this. Thanks in advance.