把短信发送出去以后,一般要把已发送的短信写入短信数据库。短信数据库有多个Uri,其中已发送的Uri是content://sms/sent。
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 |
// 把短信写入数据库public void writeMsg(){ try{ ContentValues values = new
ContentValues(); // 发送时间 values.put("date", System.currentTimeMillis()); // 阅读状态 values.put("read", 0); // 类型:1为收,2为发 values.put("type", 2); // 发送号码 values.put("address",smsWidget.str_number); // 发送内容 values.put("body", content); // 插入短信库 }catch
(Exception e) { Log.d("Exception", e.getMessage()); } } |
定义一个新的ContentValues,将短信的相关数据put进去,然后getContentResolver().insert()就可以了。
原文:http://www.cnblogs.com/mstk/p/3659177.html