Search code examples
androideditstockcalllog

Accessing Call Log


Is there a way to access the Dialer/Contacts/Call Log of Android through an application?
I essentially want to add features/information, and I know that those databases are unable to be changed past queries and insertions, so I was wondering how to override the stock Dialer/Contacts/Call Log? Preferably, I'd only like to change one of those, but any info will help.


Solution

  • Query android.provider.CallLog.Calls.CONTENT_URI for getting Callogs as:

    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
            };
    String strOrder = android.provider.CallLog.Calls.DATE + " DESC"; 
    
    Cursor mCallCursor = getContentResolver().query(
            android.provider.CallLog.Calls.CONTENT_URI,
            strFields,
            null,
            null,
            strOrder
            );
    

    and in manifest.xml add:

    <uses-permission android:name="android.permission.READ_CONTACTS"></uses-permission>