我的实现是这样 不过执行都不行 求高手 解惑
/***
* 根据条件查找 条数
* TODO
* @param where 条件 格式为"date between ? and ?"
* @param args
* @return
*/
public int getCount(){
int count=0;
String[] projection = new String[] { "count(*) as count, thread_id"}; // type=1是收件箱,==2是发件箱;read=0表示未读,read=1表示读过,sreturn
// smsInfoList;
//条件
String where ="datetime(date)<=datetime(?) and datetime(date)>=datetime(?)";
//调试时间
SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM-dd HH:mm:SS");
Calendar cdd=Calendar.getInstance();
cdd.setTime(new Date());
String[] args=new String[2];
args[0]=sf.format(cdd.getTime());
//String now=sf.format(new Date());
cdd.add(Calendar.DATE, -5);
args[1]=sf.format(cdd.getTime());
Cursor cursor = conResolver.query(Uri.parse(SMS_URI), projection, where,
args, "date DESC");
if(cursor.moveToFirst()){
int countId=cursor.getColumnIndex("count");
count=cursor.getInt(countId);
}
cursor.close();
cursor=null;
return count;
}Android短信获取根据时间统计
/***
* 根据条件查找 条数
* TODO
* @param where 条件 格式为"date between ? and ?"
* @param args
* @return
*/
public int getCount(){
int count=0;
String[] projection = new String[] { "count(*) as count, thread_id"}; // type=1是收件箱,==2是发件箱;read=0表示未读,read=1表示读过,sreturn
// smsInfoList;
//条件
String where ="datetime(date)<=datetime(?) and datetime(date)>=datetime(?)";
//调试时间
SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM-dd HH:mm:SS");
Calendar cdd=Calendar.getInstance();
cdd.setTime(new Date());
String[] args=new String[2];
args[0]=sf.format(cdd.getTime());
//String now=sf.format(new Date());
cdd.add(Calendar.DATE, -5);
args[1]=sf.format(cdd.getTime());
Cursor cursor = conResolver.query(Uri.parse(SMS_URI), projection, where,
args, "date DESC");
if(cursor.moveToFirst()){
int countId=cursor.getColumnIndex("count");
count=cursor.getInt(countId);
}
cursor.close();
cursor=null;
return count;
}Android短信获取根据时间统计
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货