Exercising the Book Provider

Now that we have a book provider, we are going to show you sample code to exercise that provider. The sample code includes adding a book, removing a book, getting a count of the books, and finally displaying all the books.

Keep in mind that these are code extracts from the sample project and will not compile, because they require additional dependency files. However, we feel this sample code is valuable in demonstrating the concepts we have explored.

At the end of this chapter, we have included a link to the downloadable sample project, which you can use in your Eclipse environment to compile and test.

Adding a Book

The code in Listing 4–9 inserts a new book into the book database.

Listing 4–9. Exercising a Provider ...

Get Pro Android 4 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.