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); }
private void insertReadAuthor() { ContentValues authorValues = com.ogasimli.alexandria.TestDb.getAuthorValues(); Uri authorUri = mContext .getContentResolver() .insert(AlexandriaContract.AuthorEntry.CONTENT_URI, authorValues); long authorRowId = ContentUris.parseId(authorUri); assertTrue(authorRowId != -1); assertEquals(authorRowId, com.ogasimli.alexandria.TestDb.ean); Cursor cursor = mContext .getContentResolver() .query( AlexandriaContract.AuthorEntry.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, authorValues); cursor = mContext .getContentResolver() .query( AlexandriaContract.AuthorEntry.buildAuthorUri(authorRowId), 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, authorValues); }