Public static final class Book TableMeta Data implements Base Columns

private BookTableMetaData() {}

public static final String TABLE_NAME = "books";

//uri and MIME type definitions public static final Uri CONTENTJJRI =

Uri.parse("content://" + AUTHORITY + "/books");

public static final String CONTENT_TYPE =

"vnd.android.cursor.dir/vnd.androidbook.book";

public static final String CONTENT_ITEM_TYPE =

"vnd.android.cursor.item/vnd.androidbook.book";

public static final String DEFAULT_SORT_ORDER = "modified DESC";

//Additional Columns start here. //string type public static final String BOOK_NAME = "name"; //string type public static final String BOOK_ISBN = "isbn"; //string type public static final String BOOK_AUTHOR = "author";

//Integer from System.currentTimeMillis()

public static final String CREATED_DATE = "created";

//Integer from System.currentTimeMillis()

public static final String MODIFIED_DATE = "modified";

This BookProviderMetaData class starts by defining its authority to be com.androidbook. provider.BookProvider. We are going to use this string to register the provider in the Android manifest file. This string forms the front part of the URIs intended for this provider.

This class then proceeds to define its one table (books) as an inner BookTableMetaData class. The BookTableMetaData class then defines a URI for identifying a collection of books. Given the authority in the previous paragraph, the URI for a collection of books will look like this:

content://com.androidbook.provider.BookProvider/books

This URI is indicated by the constant

BookProviderMetaData.BookTableMetaData.CONTENT URI

The BookTableMetaData class then proceeds to define the MIME types for a collection of books and a single book. The provider implementation will use these constants to return the MIME types for the incoming URIs.

BookTableMetaData then defines the set of columns: name, isbn, author, created (creation date), and modified (last-updated date).

0 0

Post a comment