A (175)

(Tuis.) #1

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


Since you added an electedViceroy name String to the addGalaxyViceroy method to pass it into
the RawContacts database, let’s also add new Viceroy names (using quotes) in your three method
calls, as shown in Figure 14-38.


Figure 14-38. Add String values to the addGalaxyViceroy( ) method calls in the three button event handler structures


Figure 14-39. Create Uri object named newUri and use the getContentResolver( ).insert( ) method chain to load it


Copy the .put( ) method call that loads the RawContacts.ACCOUNT_NAME table with the Viceroy
name and paste it underneath itself. Change ACCOUNT_NAME to ACCOUNT_TYPE in order
to put the name into this data table. Next, create a Uri object named newUri and load it with the
getContentResolver( ).insert( ) method call. Insert the viceroyContact ContentValues object into
the RawContacts database using the CONTENT_URI. See Figure 14-39.

Free download pdf