ここで何か誤解していますか?Android で ContentProvider を実装しようとしていますが、何らかの理由で呼び出し元の URI が一致しません。私の ContentProvider では、次を定義します。
private static final int GET_COURSES = 100;
public static final Uri COURSES_URI = Uri.withAppendedPath(CONTENT_URI, CourseTable.NAME);
private static final UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH);
static
{
matcher.addURI(AUTHORITY, COURSES_URI.toString(), GET_COURSES);
}
次に、クエリ呼び出しで:
public Cursor query(Uri uri, ...)
{
int type = matcher.match(uri);
.
.
ここでは、型は常に -1 です... デバッグ ウィンドウで、uri と COURSES_URI の両方の受け渡しを確認しましたが、文字列表現は同じです...
助言がありますか?
ありがとう
アップデート:
以下を使用してコンテンツ プロバイダーを呼び出します。
new CursorLoader(this, CoursesProvider.COURSES_URI, null, null, null, null);
...これは私の頭を悩ませています... uri.equals(COURSES_URI) == trueを得たので、UriMatcherで何かが間違っているに違いありません