在android收件箱中创建一条短信
2013-03-20 16:53
387 查看
public void recordSMSInDataBase(String phonenumber,String msg,Context context) {
ContentValues values = new ContentValues();
values.put("address",phonenumber);//user's phone number
values.put("type", "1");
values.put("read", "1");
values.put("body",msg);
Date now = new Date(System.currentTimeMillis());
DateFormat d1 = DateFormat.getDateTimeInstance(DateFormat.LONG,DateFormat.LONG); //默认语言(汉语)下的默认风格(MEDIUM风格,比如:2008-6-16 20:54:53)
String str1 = d1.format(now);
values.put("date", str1); //date
Log.i("xxx", "time = "+str1);
Uri uri = context.getContentResolver().insert(
Uri.parse("content://sms/outbox"), values); //写入
Log.i("xxx", "欧了!~");
}
数据库中sms相关的字段如下:
_id 一个自增字段,从1开始
thread_id 序号,同一发信人的id相同
address 发件人手机号码
person 联系人列表里的序号,陌生人为null
date 发件日期
protocol 协议,分为: 0 SMS_RPOTO, 1 MMS_PROTO
read 是否阅读 0未读, 1已读
status 状态 -1接收,0 complete, 64 pending, 128 failed
type
ALL = 0;
INBOX = 1;
SENT = 2;
DRAFT = 3;
OUTBOX = 4;
FAILED = 5;
QUEUED = 6;
body 短信内容
service_center 短信服务中心号码编号
subject 短信的主题
reply_path_present TP-Reply-Path
locked
android手机中
收件箱发件人 显示的规则是:如果联系人列表里没有,显示电话号!如果联系列表里有,就显示联系人!
不会联系人,电话一起显示的。
最后加入权限
<uses-permission android:name="android.permission.READ_SMS"/>
<uses-permission android:name="android.permission.WRITE_SMS"/>
相关文章推荐
- 无废话Android之listview入门,自定义的数据适配器、采用layoutInflater打气筒创建一个view对象、常用数据适配器ArrayAdapter、SimpleAdapter、使用ContentProvider(内容提供者)共享数据、短信的备份、插入一条记录到系统短信应用(3)
- 收件箱里创建一条新的未读短信的操作
- 在收件箱创建短信
- android 访问SMS短信收件箱
- 【手机勤务员】android自动切断来电,如果是手机号码回复一条短信
- 一条短信控制你的手机! Android平台的SQL注入漏洞浅析
- [android] 插入一条记录到系统短信应用里
- Android 插入一条短信
- Android-节日短信送祝福(UI篇:2-展示节日列表的Framgment的创建)
- Android 简单创建一条通知
- Android 向系统发送一条短信
- android中插入一条SMS短信内容(可用于恢复SMS短信操作)
- symbian在收件箱创建短信(转)
- android发送短信并监听插入收件箱的方法
- Android 通过BroadcastReceiver创建短信接收程序
- android sendTextMessage每发送一条短信都弹权限提示
- android手机开发之读取收件箱中指定号码短信
- Android 使用内容解析者往短信数据库里插入一条数据
- Android中一条最长短信所占的字节数
- android添加一条短信记录