Hi Guys,

I have created a ContentProvider as explained in Notepad example.
But I am getting the below errors when i am trying to access the content
Provider in my TestActivity.

*ERROR LOGS :*
*"I/ActivityManager(  569): Start proc com.example.contactprofile for
activity com.example.contactprofile/.TestContactProfileCP: pid=1659
uid=10027 gids={}
D/AndroidRuntime( 1652): Shutting down VM
D/dalvikvm( 1652): DestroyJavaVM waiting for non-daemon threads to exit
D/dalvikvm( 1652): DestroyJavaVM shutting VM down
D/dalvikvm( 1652): HeapWorker thread shutting down
D/dalvikvm( 1652): HeapWorker thread has shut down
D/jdwp    ( 1652): JDWP shutting down net...
D/jdwp    ( 1652): +++ peer disconnected
I/dalvikvm( 1652): Debugger has detached; object registry had 1 entries
D/dalvikvm( 1652): VM cleaning up
D/dalvikvm( 1652): LinearAlloc 0x0 used 639228 of 4194304 (15%)
I/jdwp    ( 1659): received file descriptor 10 from ADB
E/ActivityThread( 1659): Failed to find provider info for
com.example.provider.contactprofile
I/ActivityManager(  569): Displayed activity
com.example.contactprofile/.TestContactProfileCP: 569 ms"*

*Here is my Code snippet ...*

*Manifest.xml*
    <provider android:name=".ContactProfileContentProvider"
          android:authorities="com.example.contactprofile" />

*My ContentProvider Class is  :*
package com.example.contactprofile;
public class ContactProfileContentProvider extends ContentProvider
{
public static final Uri CONTENT_URI = Uri

.parse("content://com.example.provider.contactprofile/contactprofiles");

// Create the constants used to differentiate between the different URI
    // requests.
    private static final int PROFILES = 1;
    private static final int PROFILE_ID = 2;

    private static final UriMatcher uriMatcher;
    // Allocate the UriMatcher object, where a URI ending in
‘contactprofiles’
    // will correspond to a request for all earthquakes, and
‘contactprofiles’
    // with a trailing ‘/[rowID]’ will represent a single contact profile
row.
    static {
        uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
        uriMatcher.addURI("com.example.provider.ContactProfile",
                "contactprofiles", PROFILES);
        uriMatcher.addURI("com.example.provider.ContactProfile",
                "contactprofiles/#", PROFILE_ID);
    }
    // The underlying database
    private SQLiteDatabase contactProfileDB;
    private static final String TAG = "ContactProfileContentProvider";
    private static final String DATABASE_NAME = "ContactProfiles.db";
    private static final int DATABASE_VERSION = 2;
    private static final String PROFILE_TABLE = "contactprofile";

    // Column Names
    public static final String PID = "_id";
    public static final String CONTACT_ID = "contact_id";
    public static final String FIRST_NAME = "fname";
    public static final String LAST_NAME = "lname";

    private static final String DATABASE_CREATE = "create table "
                + PROFILE_TABLE + " ("
                + PID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + CONTACT_ID
                + " INTEGER NOT NULl, " + FIRST_NAME + " TEXT, " + LAST_NAME
                + " TEXT);";
    @Override
    public boolean onCreate() {
        Log.d(TAG, " Entering onCreate () ..."); // This Log is not printing
at all
        db.execSQL(DATABASE_CREATE);
    }

*** In my Test activity am calling the above ContentProvider as below :

Cursor cursor = managedQuery(ContactProfileContentProvider.CONTENT_URI,
                                 projection,          // Which columns to
return
                                 null,       // Which rows to return (all
rows)
                                 null,       // Selection arguments (none)
                                 null);

But here the null cursor  object is being returned.

Can any one tell me where i am wrong.
What are the conditions to make "onCreate()" to be called when my Activity
is launching?

Your help is highly apreciated.

Thanks,
Ratnakar A.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to