Usuń SMS z contentResolver jest zbyt wolny
Chciałbym usunąć wszystkie SMS-y z mojego telefonu z wyjątkiem 500 ostatnich SMS-ów dla każdej rozmowy. To jest mój kod, ale jest bardzo powolny (usunięcie jednego SMSa zajmuje około 10 sekund). Jak mogę przyspieszyć ten kod:
ContentResolver cr = getContentResolver();
Uri uriConv = Uri.parse("content://sms/conversations");
Uri uriSms = Uri.parse("content://sms/");
Cursor cConv = cr.query(uriConv,
new String[]{"thread_id"}, null, null, null);
while(cConv.moveToNext()) {
Cursor cSms = cr.query(uriSms,
null,
"thread_id = " + cConv.getInt(cConv.getColumnIndex("thread_id")),
null, "date ASC");
int count = cSms.getCount();
for(int i = 0; i < count - 500; ++i) {
if (cSms.moveToNext()) {
cr.delete(
Uri.parse("content://sms/" + cSms.getInt(0)),
null, null);
}
}
cSms.close();
}
cConv.close();