Changes

Jump to: navigation, search

Implementing an Android Content Provider in Android Studio

21 bytes removed, 08:08, 28 January 2016
m
Text replacement - "<google>BUY_ANDROID_STUDIO6</google>" to "<htmlet>androidstudio_a6</htmlet>"
<googlehtmlet>BUY_ANDROID_STUDIO6androidstudio_a6</googlehtmlet>
Finally, these two string elements are combined, prefixed with content:// and converted to a Uri object using the parse() method of the Uri class. The result is assigned to a variable named CONTENT_URI.
<googlehtmlet>BUY_ANDROID_STUDIO6androidstudio_a6</googlehtmlet>
== Implementing URI Matching in the Content Provider ==
The UriMatcher instance (named sURIMatcher) is now primed to return the value of PRODUCTS when just the products table is referenced in a URI, and PRODUCTS_ID when the URI includes the ID of a specific row in the table.
<googlehtmlet>BUY_ANDROID_STUDIO6androidstudio_a6</googlehtmlet>
== Implementing the Content Provider onCreate() Method ==
}
</pre>
<googlehtmlet>BUY_ANDROID_STUDIO6androidstudio_a6</googlehtmlet>
== Implementing the Content Provider update() Method ==
All that remains before testing the application is to modify the database handler class to use the content provider instead of directly accessing the database.
<googlehtmlet>BUY_ANDROID_STUDIO6androidstudio_a6</googlehtmlet>
== Modifying the Database Handler ==
}
</pre>
<googlehtmlet>BUY_ANDROID_STUDIO6androidstudio_a6</googlehtmlet>
Next, the addProduct(), findProduct() and removeProduct() methods need to be re-written to use the content resolver and content provider for data management purposes:
<googlehtmlet>BUY_ANDROID_STUDIO6androidstudio_a6</googlehtmlet>

Navigation menu