PDA

View Full Version : Uri و UriMatcher ؟



fshb_ 1370
یک شنبه 15 اردیبهشت 1392, 17:57 عصر
سلام دوستان
این جوری که من فهمیدم Uri وظیفش رفتن به table و db موردنظر ما و گرفتن data از آنهاست. درسته؟
Uri طرز نوشتنش به صورت خاصیه، مثلا scheme,content و... . من این رو درک نمیکنم :( میشه یکمی توضیح بدید)

UriMatcher چیه؟ چه کاربردی داره؟

private static final int TODOS = 10;
private static final int TODO_ID = 20;

private static final String AUTHORITY = "de.vogella.android.todos.contentprovider";

private static final String BASE_PATH = "todos";
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY
+ "/" + BASE_PATH);

public static final String CONTENT_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE
+ "/todos";
public static final String CONTENT_ITEM_TYPE = ContentResolver.CURSOR_ITEM_BASE_TYPE
+ "/todo";

private static final UriMatcher sURIMatcher = new UriMatcher(UriMatcher.NO_MATCH);
static {
sURIMatcher.addURI(AUTHORITY, BASE_PATH, TODOS);
sURIMatcher.addURI(AUTHORITY, BASE_PATH + "/#", TODO_ID);
}

کد بالا رو ببینید. چرا توی این کد TODO و TODO_ID رو تعریف میکنن؟

ممنون