private void insertReadBook() { ContentValues bookValues = com.ogasimli.alexandria.TestDb.getBookValues(); Uri bookUri = mContext.getContentResolver().insert(AlexandriaContract.BookEntry.CONTENT_URI, bookValues); long bookRowId = ContentUris.parseId(bookUri); assertTrue(bookRowId != -1); Cursor cursor = mContext .getContentResolver() .query( AlexandriaContract.BookEntry.CONTENT_URI, null, // leaving "columns" null just returns all the columns. null, // cols for "where" clause null, // values for "where" clause null // sort order ); com.ogasimli.alexandria.TestDb.validateCursor(cursor, bookValues); cursor = mContext .getContentResolver() .query( AlexandriaContract.BookEntry.buildBookUri(bookRowId), null, // leaving "columns" null just returns all the columns. null, // cols for "where" clause null, // values for "where" clause null // sort order ); com.ogasimli.alexandria.TestDb.validateCursor(cursor, bookValues); }
public void testGetType() { String type = mContext.getContentResolver().getType(AlexandriaContract.BookEntry.CONTENT_URI); assertEquals(AlexandriaContract.BookEntry.CONTENT_TYPE, type); type = mContext.getContentResolver().getType(AlexandriaContract.AuthorEntry.CONTENT_URI); assertEquals(AlexandriaContract.AuthorEntry.CONTENT_TYPE, type); type = mContext.getContentResolver().getType(AlexandriaContract.CategoryEntry.CONTENT_URI); assertEquals(AlexandriaContract.CategoryEntry.CONTENT_TYPE, type); long id = 9780137903955L; type = mContext.getContentResolver().getType(AlexandriaContract.BookEntry.buildBookUri(id)); assertEquals(AlexandriaContract.BookEntry.CONTENT_ITEM_TYPE, type); type = mContext.getContentResolver().getType(AlexandriaContract.BookEntry.buildFullBookUri(id)); assertEquals(AlexandriaContract.BookEntry.CONTENT_ITEM_TYPE, type); type = mContext.getContentResolver().getType(AlexandriaContract.AuthorEntry.buildAuthorUri(id)); assertEquals(AlexandriaContract.AuthorEntry.CONTENT_ITEM_TYPE, type); type = mContext .getContentResolver() .getType(AlexandriaContract.CategoryEntry.buildCategoryUri(id)); assertEquals(AlexandriaContract.CategoryEntry.CONTENT_ITEM_TYPE, type); }