[Android programming] how to operate call logs

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.