Android Phone defender 8--delete Call history

Source: Internet
Author: User
<span id="Label3"></p><p><p><strong><span style="line-height: 1.5">1. Write code that requires attention to bugs:</span></strong></p></p><p><p>Delete the call log, Delete the previous call history, the interception of the phone number, the call record is not deleted??????<br>Cause: the phone number of this call record in the database has not been inserted, did delete operation</p></p><p><p><strong>2.bug workaround:</strong></p></p><p><p>Content Provider: provides access to the database for external users<br>Content parser: access the database using the access method provided by the content provider (add-and-scan)<br>Content Watcher: Observe the changes in the database, and call the corresponding method once the data has changed</p></p><p><p>Through the content viewer, observe the insertion of the database, once inserted, do delete this insert data operation</p></p><pre class="brush:java;gutter:true;"><pre class="brush:java;gutter:true;">public void Endcall (String phone) {...//6, on the content parser, goes to register the content observer, through the content viewer, to observe the changes in the database (uri determines the library of that table) mcontentobserver = new Mycontentobserver (new Handler (), phone), getcontentresolver (). registercontentobserver (uri.parse ("content://call_ Log/calls "), true, mcontentobserver);}}</pre></pre><p><p></p></p><pre class="brush:java;gutter:true;"><pre class="brush:java;gutter:true;">Class Mycontentobserver extends Contentobserver{private String phone;public mycontentobserver (Handler handler,string Phone) {super (handler); this.phone = phone;} When the specified calls table in the database changes, the method is called @overridepublic void OnChange (boolean Selfchange) {//inserts a data, and then deletes Getcontentresolver (). Delete (uri.parse ("content://call_log/calls"), "number =?", new string[]{phone}); super.onchange (selfchange);}}</pre></pre><p><p>  </p></p><p><p>  </p></p><p><p>Android Phone defender 8--delete Call history</p></p></span>

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.