Android implements the method of writing the sent SMS to the SMS database _android

Source: Internet
Author: User

SMS is a common function of mobile phone, this article is an example of the implementation of the Android will be sent to the text message database method. Share for everyone to use for reference. Specifically as follows:

Generally speaking, after sending the text message, you need to write the text message into the SMS database. The SMS database has multiple URIs, in which the URI sent is content://sms/sent.

The specific function code is as follows:

Write SMS to database public
void Writemsg () {
   
  try{
    contentvalues values = new Contentvalues ();
    Send Time
    values.put ("date", System.currenttimemillis ());
    Reading status      
    values.put ("read", 0);
    Type: 1 for receiving, 2 for hair      
    values.put ("type", 2);
    Send number      
    values.put ("Address", smswidget.str_number);
    Send content     
    values.put ("Body", content);
    Insert SMS Library 
    getcontentresolver (). Insert (Uri.parse ("content://sms/sent"), values);      
  catch (Exception e) { 
        log.d ("Exception", E.getmessage ()); 
  }


Define a new contentvalues, put the relevant data into the text message, and then Getcontentresolver (). Insert () is OK.

I hope this article will help you with your Android program.

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.