Steps to create a Content Provider in Android

1. Define strings for provider mime type, item mime type & for authority

    <string name="[OBJECT]_CONTENT_TYPE">[initials].[object]</string>
    <string name="[OBJECT]_CONTENT_TYPE_DIR">[initials].[object]</string>
    <string name="[OBJECT]_CONTENT_COMMENT_DIR_URI">"content://com.[initials].[object]Provider/[object]"</string>
    <string name="[OBJECT]_CONTENT_COMMENT_AUTHORITY">"com.[initials].[object]Provider"</string>

2. Create metadata class

3. Create authority and sql helper private class

4. Define authority in androidmanifest.xml

<provider android:name="[Object]Provider" android:label="@string/app_name"                      android:authorities="@string/[OBJECT]_CONTENT_COMMENT_AUTHORITY"></provider>

5. profit

That is all.

One Comment

  1. Prateek Pandey says:

    this is nice post, thanks buddy! for sharing with us.
    For another nice and understandable article related to this post check out this url link..

Leave a Reply to Prateek Pandey


Contact Nixz Kerr