@Override
 public boolean onCreate() {
   setAppOps(AppOpsManager.OP_READ_SMS, AppOpsManager.OP_WRITE_SMS);
   mOpenHelper = MmsSmsDatabaseHelper.getInstanceForCe(getContext());
   TelephonyBackupAgent.DeferredSmsMmsRestoreService.startIfFilesExist(getContext());
   return true;
 }
 @Override
 public boolean onCreate() {
   setAppOps(AppOpsManager.OP_READ_SMS, AppOpsManager.OP_WRITE_SMS);
   mOpenHelper = MmsSmsDatabaseHelper.getInstance(getContext());
   return true;
 }
  @Override
  public int delete(Uri url, String where, String[] whereArgs) {
    int count;
    int match = sURLMatcher.match(url);
    SQLiteDatabase db = mOpenHelper.getWritableDatabase();
    switch (match) {
      case SMS_ALL:
        count = db.delete(TABLE_SMS, where, whereArgs);
        if (count != 0) {
          // Don't update threads unless something changed.
          MmsSmsDatabaseHelper.updateAllThreads(db, where, whereArgs);
        }
        break;

      case SMS_ALL_ID:
        try {
          int message_id = Integer.parseInt(url.getPathSegments().get(0));
          count = MmsSmsDatabaseHelper.deleteOneSms(db, message_id);
        } catch (Exception e) {
          throw new IllegalArgumentException("Bad message id: " + url.getPathSegments().get(0));
        }
        break;

      case SMS_CONVERSATIONS_ID:
        int threadID;

        try {
          threadID = Integer.parseInt(url.getPathSegments().get(1));
        } catch (Exception ex) {
          throw new IllegalArgumentException(
              "Bad conversation thread id: " + url.getPathSegments().get(1));
        }

        // delete the messages from the sms table
        where = DatabaseUtils.concatenateWhere("thread_id=" + threadID, where);
        count = db.delete(TABLE_SMS, where, whereArgs);
        MmsSmsDatabaseHelper.updateThread(db, threadID);
        break;

      case SMS_RAW_MESSAGE:
        count = db.delete("raw", where, whereArgs);
        break;

      case SMS_STATUS_PENDING:
        count = db.delete("sr_pending", where, whereArgs);
        break;

      case SMS_ICC:
        String messageIndexString = url.getPathSegments().get(1);

        return deleteMessageFromIcc(messageIndexString);

      default:
        throw new IllegalArgumentException("Unknown URL");
    }

    if (count > 0) {
      notifyChange(url);
    }
    return count;
  }