안녕하세요 친구 삭제 sms를 만듭니다. sms를 성공적으로 삭제하지만 한 SMS 만 삭제하고 싶습니다. 가능하면 가능할 수 있습니다. 코드가 있으면 나를 보내주십시오. 도와주세요.android 응용 프로그램에서받은 편지함에서 하나의 SMS 만 삭제합니다
미리 감사드립니다.
안녕하세요 친구 삭제 sms를 만듭니다. sms를 성공적으로 삭제하지만 한 SMS 만 삭제하고 싶습니다. 가능하면 가능할 수 있습니다. 코드가 있으면 나를 보내주십시오. 도와주세요.android 응용 프로그램에서받은 편지함에서 하나의 SMS 만 삭제합니다
미리 감사드립니다.
동일한 것을 찾고 있습니다.
나는 그것이 작동하는지 확인 카운트이 코드를 사용하고 있습니다 :
public void deleteOneSMS(int threadIdNo) {
try {
Uri uriSms = Uri.parse("content://sms/inbox");
Cursor c = getContentResolver().query(uriSms,new String[] { "_id", "thread_id" }, null, null, null);
if (c != null && c.move(threadIdNo)) {
do {
long threadId = c.getLong(1);
count++;
//System.out.println("threadId:: "+threadId);
if (count == threadIdNo){
getContentResolver().delete(
Uri.parse("content://sms/conversations/" + threadId),
null, null);
}
} while (c.moveToNext());
}
}catch (Exception e) {
// TODO: handle exception
System.out.println("Exception:: "+e);
}
}
을 한 번하고 모든 대화에 하나의 SMS를 삭제하려면,이 예는 내가 여기 당신을 도울 것입니다 lates (가장 많이 쓰는) SMS를받은 편지함에서 가져 와서 삭제합니다. 각 SMS에는 다른 SMS와 구별되는 스레드 및 id 값이 있습니다.
try
{
Uri uri = Uri.parse("content://sms/inbox");
Cursor c =v.getContext().getContentResolver().query(uri, null, null ,null,null);
String body = null;
String number = null;
if(c.moveToFirst())
{}
}
catch(CursorIndexOutOfBoundsException ee)
{
Toast.makeText(v.getContext(), "Error :"+ ee.getMessage() ,Toast.LENGTH_LONG).show();
}
이 코드를 사용하기 만하면됩니다.
try {
Uri uriSms = Uri.parse("content://sms/inbox");
Cursor c = context.getContentResolver().query(
uriSms,
new String[] { "_id", "thread_id", "address", "person",
"date", "body" }, "read=0", null, null);
if (c != null && c.moveToFirst()) {
do {
long id = c.getLong(0);
long threadId = c.getLong(1);
String address = c.getString(2);
String body = c.getString(5);
String date = c.getString(3);
if (message.equals(body) && address.equals(number)) {
// mLogger.logInfo("Deleting SMS with id: " + threadId);
context.getContentResolver().delete(
Uri.parse("content://sms/" + id), "date=?",
new String[] { <your date>});
Log.e("log>>>", "Delete success.........");
}
} while (c.moveToNext());
}
} catch (Exception e) {
Log.e("log>>>", e.toString());
}