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.