提取sms表中数据
2016-09-01 10:46
148 查看
sms表的结构,需要使用root才能在data/data中看到
代码如下:
ContentResolver cr = getContentResolver();
//你需要什么字段,就在这里写,短信内容,手机号,在手机里的联系人名称
String[] projection = new String[] { "body", "address", "person" };// "_id",
// "address",
// "person",, "date",
// "type
//也可以加条件
String where = " date > " + (System.currentTimeMillis() - 10 * 60 * 1000);
//得到cursor对象,剩下的处理跟数据表的处理方法一样
Cursor cur = cr.query(SMS_INBOX, projection, where, null, "date desc");
if (null == cur)
return;
while (cur.moveToNext()) {
int address = cur.getColumnIndex("address");
Log.i("tag", "address:" + address);
String number = "";
if (address != -1) {
number = cur.getString(address);// 手机号
}
String name = "";
int person = cur.getColumnIndex("person");
Log.i("tag", "person:" + person);
if (cur.getColumnIndex("person") != -1) {
name = cur.getString(cur.getColumnIndex("person"));// 联系人姓名列表
}
String body = "";
body = cur.getString(cur.getColumnIndex("body"));
Log.i("tag", "address:" + number + "body:" + body);
}
代码如下:
ContentResolver cr = getContentResolver();
//你需要什么字段,就在这里写,短信内容,手机号,在手机里的联系人名称
String[] projection = new String[] { "body", "address", "person" };// "_id",
// "address",
// "person",, "date",
// "type
//也可以加条件
String where = " date > " + (System.currentTimeMillis() - 10 * 60 * 1000);
//得到cursor对象,剩下的处理跟数据表的处理方法一样
Cursor cur = cr.query(SMS_INBOX, projection, where, null, "date desc");
if (null == cur)
return;
while (cur.moveToNext()) {
int address = cur.getColumnIndex("address");
Log.i("tag", "address:" + address);
String number = "";
if (address != -1) {
number = cur.getString(address);// 手机号
}
String name = "";
int person = cur.getColumnIndex("person");
Log.i("tag", "person:" + person);
if (cur.getColumnIndex("person") != -1) {
name = cur.getString(cur.getColumnIndex("person"));// 联系人姓名列表
}
String body = "";
body = cur.getString(cur.getColumnIndex("body"));
Log.i("tag", "address:" + number + "body:" + body);
}
相关文章推荐
- Item01: 数据提取(Data Abstraction)
- 从数据库提取出数据修改后让datagird显示
- 怎样从wav文件中提取记录频率的数据
- 如何实现快速地从超大数据库中提取数据并进行相关的操作
- php录入页面中动态从数据库中提取数据的实现
- 学习如何把数据库数据提取为XML(转)
- 采用POI和ANTLR提取WORD文档数据
- Nuva 示例代码(每日一帖)之 数据架构提取
- 使用 Linux 文本工具简化数据的提取
- 信息系统的快速开发(3)数据信息的提取
- 一句SQL语句解决倒序数据分页提取
- 以实例说明如何使用C#从数据库中提取数据,按要求自动生成定制的Excel表格?[转]
- 探讨如何在有着1000万条数据的MS SQL SERVER数据库中实现快速的数据提取和数据分页
- 提取表单中的所有数据
- SQL实现随机提取数据
- SMS PDU模式,数据格式和长度计算
- VC++实现GPS全球定位系统定位数据的提取
- VC++实现串口通信下GP接收机定位数据的提取
- php录入页面中动态从数据库中提取数据的实现
- 关于NTKO_office的操作(从数据库中提取数据,写入到NTKO_office_Word中)