Delete messages

This commit is contained in:
Moez Bhatti
2016-06-28 02:33:34 -04:00
parent e5d6ddc6fc
commit 1d86059469
@@ -5,7 +5,6 @@ import android.app.IntentService;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.database.Cursor;
import android.util.Log; import android.util.Log;
import com.moez.QKSMS.common.QKPreferences; import com.moez.QKSMS.common.QKPreferences;
import com.moez.QKSMS.enums.QKPreference; import com.moez.QKSMS.enums.QKPreference;
@@ -56,23 +55,12 @@ public class DeleteOldMessagesService extends IntentService {
} }
private int deleteOldMessages(Context context, String selection, long before) { private int deleteOldMessages(Context context, String selection, long before) {
Cursor cursor = null;
selection += " AND " + SmsHelper.COLUMN_DATE + "<=?"; selection += " AND " + SmsHelper.COLUMN_DATE + "<=?";
try { try {
cursor = context.getContentResolver().query( return context.getContentResolver().delete(SmsHelper.SMS_CONTENT_PROVIDER, selection, new String[]{String.valueOf(before)});
SmsHelper.SMS_CONTENT_PROVIDER,
new String[]{SmsHelper.COLUMN_ID, SmsHelper.COLUMN_DATE},
selection,
new String[]{String.valueOf(before)},
null);
return cursor.getCount();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally {
if (cursor != null) {
cursor.close();
}
} }
return 0; return 0;