Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1d860594 authored by Moez Bhatti's avatar Moez Bhatti
Browse files

Delete messages

parent e5d6ddc6
Loading
Loading
Loading
Loading
+1 −13
Original line number Diff line number Diff line
@@ -5,7 +5,6 @@ import android.app.IntentService;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.util.Log;
import com.moez.QKSMS.common.QKPreferences;
import com.moez.QKSMS.enums.QKPreference;
@@ -56,23 +55,12 @@ public class DeleteOldMessagesService extends IntentService {
    }

    private int deleteOldMessages(Context context, String selection, long before) {
        Cursor cursor = null;
        selection += " AND " + SmsHelper.COLUMN_DATE + "<=?";

        try {
            cursor = context.getContentResolver().query(
                    SmsHelper.SMS_CONTENT_PROVIDER,
                    new String[]{SmsHelper.COLUMN_ID, SmsHelper.COLUMN_DATE},
                    selection,
                    new String[]{String.valueOf(before)},
                    null);
            return cursor.getCount();
            return context.getContentResolver().delete(SmsHelper.SMS_CONTENT_PROVIDER, selection, new String[]{String.valueOf(before)});
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (cursor != null) {
                cursor.close();
            }
        }

        return 0;