我厌倦了这个问题,实际上不知道问题出在哪里,下面是我的代码:
private void readSMS() throws IOException {
// TODO Auto-generated method stub
Log.d("Read SMS","Called");
ContentResolver cr = context.getContentResolver();
Uri uri = Uri.parse("content://sms/inbox");
StringBuilder smsBackup = new StringBuilder();
Cursor messagesCursor = cr.query(uri, new String[] { "_id","address","body","person"}, null,null, null);
smsBackup.append("SMS Back UP (Total Message(s)::"+messagesCursor.getCount()+") \n\n");
String name = null;
if(messagesCursor.getCount() > 0){
while(messagesCursor.moveToNext()){
name = null;
name = getName(messagesCursor.getString(messagesCursor.getColumnIndex("address")));
if(name==null)
name = "Sender : " + messagesCursor.getString(messagesCursor.getColumnIndex("address"));
smsBackup.append("Sender : "+name +"\n"+ "Message : "+messagesCursor.getString(messagesCursor.getColumnIndex("body")) + "\n\n");
}
}
Log.d("InSMS Lenght","::"+smsBackup.toString().length());
}
这是日志猫消息:W/CursorWrapperInner(8375): Cursor finalized without prior close()