0
查看ContentProviders
的示例時,其中大多數包含BaseColumns
接口。比較不同的實現時,每個實現中都有不同的方法。在BaseColumns
界面中放入什麼是最好的東西,以及不應該放入什麼?一個BaseColumns
接口的ContentProvider的BaseColumns接口,要放什麼?
實施例:
public static interface LentItems extends BaseColumns {
public static final Uri CONTENT_URI = LentItemsProvider.CONTENT_URI;
public static final String NAME = "name";
public static final String CATEGORY = "category";
public static final String BORROWER = "borrower";
public static final String CONTENT_PATH = "items";
public static final String CONTENT_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE + "/vnd.cpsample.lentitems";
public static final String CONTENT_ITEM_TYPE = ContentResolver.CURSOR_ITEM_BASE_TYPE + "/vnd.cpsample.lentitems";
public static final String[] PROJECTION_ALL = {_ID, NAME, CATEGORY, BORROWER};
public static final String SORT_ORDER_DEFAULT = NAME + " ASC";
}
另一示例
public class Note {
public Note() {
}
public static final class Notes implements BaseColumns {
private Notes() {
}
public static final Uri CONTENT_URI = Uri.parse("content://"
+ NotesContentProvider.AUTHORITY + "/notes");
public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.jwei512.notes";
public static final String NOTE_ID = "_id";
public static final String TITLE = "title";
public static final String TEXT = "text";
}
}