Android获取手机短信

在Android中,短信数据库的字段为:

_id                       短消息序号 
thread_id            对话的序号(conversation)
address               发件人地址,手机号
person                 发件人,返回一个数字就是联系人列表里的序号,陌生人为null
date                     日期  long型,想得到具体日期自己转换吧!
protocol              协议
read                     是否阅读
status                   状态
type                      类型 1是接收到的,2是发出的
reply_path_present
subject                 主题
body                     短消息内容
service_center      短信服务中心号码编号,可以得知该短信是从哪里发过来的

 

获取短信的代码为:

Uri SMS_CONTENT = Uri.parse("content://sms/"); 

Cursor cursor = context.getContentResolver().query(SMS_CONTENT,null,null,null,null);

while(cursor.moveToNext()){
          
                system.out.print(cursor.getString(cursor.getColumnIndex("address")));
              
                system.out.print(cursor.getString(cursor.getColumnIndex("body")));

            }
            
        }
 

 

 

posted on 2011-07-10 10:25  晓光  阅读(1268)  评论(1编辑  收藏  举报

导航