Android call logs are implemented in static class Android.provider.CallLog.Calls.
Permission to read and write the call log first
<uses-permission android:name= "Android.permission.READ_CALL_LOG"/><uses-permission android:name= " Android.permission.WRITE_CALL_LOG "/>
?
Read
cursor cursor = context.getcontentresolver (). Query (Calllog.calls.content_uri,new string[] {CallLog.Calls.NUMBER, Calllog.calls.cached_name,calllog.calls.type,calllog.calls.date,calllog.calls.duration}, Null,null, CallLog.Calls.DEFAULT_SORT_ORDER);
Write
Contentvalues values = new Contentvalues (); Values.put (CallLog.Calls.NUMBER, "13200000002"); Values.put ( CallLog.Calls.TYPE, CallLog.Calls.OUTGOING_TYPE); Values.put (CallLog.Calls.DATE, System.currenttimemillis ()); Values.put (CallLog.Calls.DURATION, 1); Context.getcontentresolver (). Insert (CallLog.Calls.CONTENT_URI, values);
Explain the meaning of each field:
public static final string number: textpublic static final String type: Call record type for inbound incoming_type, outbound Outgoing_ TYPE and missed Missed_type.
public static final string cached_name: Cached contact name, Textpublic static final string date: The time that the call occurred, Integerpublic static final S Tring DURATION: Time of the call, INTEGER
It's supposed to be so much more common.