Code example for SQLiteDatabase

Methods: deleteupdate

0
 
        switch (sUriMatcher.match(uri)) {
        case APPS:
            // Don't delete the app here, set it's allow column to -1 and 
            // mark it as dirty. The PermissionsDbService will delete it 
            count = mDb.update(Apps.TABLE_NAME, deleteAppValues, selection, selectionArgs);
            // Delete from the other DB too 
            Util.updatePermissionsDb(mContext);
            break; 
        case APP_ID:
            count = mDb.update(Apps.TABLE_NAME, deleteAppValues,
                    Apps._ID + "=" + uri.getPathSegments().get(1) +
                    (!TextUtils.isEmpty(selection)? " AND (" +
                            selection  + ")":""),
                    selectionArgs);
            Util.updatePermissionsDb(mContext);
            // No break here so we can fall through and delete associated logs 
        case APP_ID_LOGS:
        case LOGS_APP_ID:
            count += mDb.delete(Logs.TABLE_NAME,
                    Logs.APP_ID + "=" + uri.getPathSegments().get(1) +
                    (!TextUtils.isEmpty(selection)? " AND (" +
                            selection  + ")":""),
                    selectionArgs);
            break; 
        case APP_UID:
            // May remove this, I don't think I'm going to want to use it 
            count = mDb.update(Apps.TABLE_NAME, deleteAppValues,
                    Apps.UID + "=" + uri.getPathSegments().get(2) +
                    (!TextUtils.isEmpty(selection)? " AND (" +
                            selection  + ")":""),
                    selectionArgs);
            Util.updatePermissionsDb(mContext);
            break; 
        case APP_CLEAN:
            count = mDb.delete(Apps.TABLE_NAME, selection, selectionArgs);
            break; 
        case LOGS:
            count = mDb.delete(Logs.TABLE_NAME, selection, selectionArgs);
            break; 
        default: 
            throw new IllegalArgumentException("Unsupported URI: " + uri);
        } 
        getContext().getContentResolver().notifyChange(uri, null);