Dear Android Experts,

I want to get Contact id from the call log id if the number is saved in the android device.


*For Call Log I am using the following cursor.*

String[] strFields = {
             android.provider.CallLog.Calls.NUMBER,
             android.provider.CallLog.Calls.TYPE,
             android.provider.CallLog.Calls.CACHED_NAME,
             android.provider.CallLog.Calls.CACHED_NUMBER_TYPE,
             android.provider.CallLog.Calls.DATE,
             android.provider.CallLog.Calls.DURATION,
             android.provider.CallLog.Calls._ID
             };
    String strOrder = android.provider.CallLog.Calls.DATE + " DESC";

Cursor mCallCursor = getContentResolver().query(android.provider.CallLog.Calls.CONTENT_URI, strFields, null, null,strOrder);


*For Contact I am using the following cursor*

final String[] projection = new String[] {
RawContacts.CONTACT_ID, // the contact id column RawContacts.DELETED // column if this contact is deleted
        };

        final Cursor rawContacts = managedQuery(
RawContacts.CONTENT_URI, // the uri for raw contact provider
                projection,
null, // selection = null, retrieve all entries null, // not required because selection does not contain parameters
                null);



*For email I am using the following cursor*
final String[] projection = new String[] {
Email.DATA, // use Email.ADDRESS for API-Level 11+
                Email.TYPE
        };

        final Cursor email = managedQuery(
                Email.CONTENT_URI,
                projection,
                Data.CONTACT_ID + "=?",
                new String[]{String.valueOf(contactId)},
                null);


*For photo I am using the following cursor on the basis of photoid*
final Cursor photo = managedQuery(
                Data.CONTENT_URI,
new String[] {Photo.PHOTO}, // column where the blob is stored
                Data._ID + "=?",                // select row by id
new String[]{photoId}, // filter by the given photoId
                null);



*For all phone numbers of a contact I am using the following cursor*
final String[] projection = new String[] {
                Phone.NUMBER,
                Phone.TYPE,
        };

        final Cursor phone = managedQuery(
                Phone.CONTENT_URI,
                projection,
                Data.CONTACT_ID + "=?",
                new String[]{String.valueOf(contactId)},
                null);



*but I am unable to fetch contact id from call log if the corresponding number is saved in android device. According to api there is no common field to relate call log._id to Contact.Contact_ID. I don't want to iterate entire contact table for each call log entry because it will slow the software if number of phone-numbers saved in mobile is large.*

Anybody's help will be appreciated. Thanks in advance


Thanks & Regards
P B Lal

--
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