A (175)

(Tuis.) #1

536 CHAPTER 14: Android Content Providers: Providing Data to Applications


As you can see in Figure 14-27, Eclipse writes the bootstrap programming structure for the
listGalaxyRulers( ) method for you at the end of the ContactGalaxy class, complete with a
placeholder comment where your Java programming logic needs to be written. You will be replacing
this comment with the database access Java code.


Figure 14-27. The bootstrap method created by Eclipse at the end of the ContactGalaxy.java class listing


The first step will be to declare and instantiate a Cursor object named rulerCursor and load it with
the database content you are going to list using the getContentResolver( ).query( ) method call
chain. To do so, use the following line of Java code, which is shown in Figure 14-28 along with a URI
pop-up helper dialog that contains the URIs:


Cursor rulerCursor = getContentResolver().query( ContactsContract.Contacts.CONTENT_URI, null, null,
null, null );


Figure 14-28. Declare a Cursor object named rulerCursor and instantiate it using getContentResolver( ).query( )

Free download pdf