Java Code Examples for android.content.ContentProviderClient#delete()

The following examples show how to use android.content.ContentProviderClient#delete() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QuantumFluxSyncHelper.java    From QuantumFlux with Apache License 2.0 5 votes vote down vote up
public static <T> void delete(Context context, ContentProviderClient provider, T dataModelObject) throws RemoteException {
    TableDetails tableDetails = QuantumFlux.findTableDetails(dataModelObject.getClass());
    Object columnValue = ModelInflater.deflateColumn(tableDetails, tableDetails.findPrimaryKeyColumn(), dataModelObject);
    Uri itemUri = UriMatcherHelper.generateItemUriBuilder(tableDetails, String.valueOf(columnValue))
            .appendQueryParameter(QuantumFluxContentProvider.PARAMETER_SYNC, "false").build();

    provider.delete(itemUri, null, null);
}
 
Example 2
Source File: AbstractContentProviderStub.java    From DroidPlugin with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
    String targetAuthority = uri.getQueryParameter(Env.EXTRA_TARGET_AUTHORITY);
    if (!TextUtils.isEmpty(targetAuthority) && !TextUtils.equals(targetAuthority, uri.getAuthority())) {
        ContentProviderClient client = getContentProviderClient(targetAuthority);
        try {
            return client.delete(buildNewUri(uri, targetAuthority), selection, selectionArgs);
        } catch (RemoteException e) {
            handleExpcetion(e);
        }
    }
    return 0;
}
 
Example 3
Source File: CPSyncHelper.java    From CPOrm with MIT License 5 votes vote down vote up
public static <T> void delete(Context context, boolean notifyChanges, ContentProviderClient provider, T dataModelObject) throws RemoteException {
    TableDetails tableDetails = CPOrm.findTableDetails(context, dataModelObject.getClass());
    Object columnValue = ModelInflater.deflateColumn(tableDetails, tableDetails.findPrimaryKeyColumn(), dataModelObject);
    Uri itemUri = UriMatcherHelper.generateItemUri(context, tableDetails, String.valueOf(columnValue))
            .appendQueryParameter(CPOrmContentProvider.PARAMETER_SYNC, "false")
            .appendQueryParameter(CPOrmContentProvider.PARAMETER_NOTIFY_CHANGES, Boolean.toString(notifyChanges)).build();

    provider.delete(itemUri, null, null);
}
 
Example 4
Source File: FileDataStorageManager.java    From Cirrus_depricated with GNU General Public License v2.0 4 votes vote down vote up
public void deleteFileInMediaScan(String path) {

        String mimetypeString = FileStorageUtils.getMimeTypeFromName(path);
        ContentResolver contentResolver = getContentResolver();

        if (contentResolver != null) {
            if (mimetypeString.startsWith("image/")) {
                // Images
                contentResolver.delete(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
                        MediaStore.Images.Media.DATA + "=?", new String[]{path});
            } else if (mimetypeString.startsWith("audio/")) {
                // Audio
                contentResolver.delete(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
                        MediaStore.Audio.Media.DATA + "=?", new String[]{path});
            } else if (mimetypeString.startsWith("video/")) {
                // Video
                contentResolver.delete(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
                        MediaStore.Video.Media.DATA + "=?", new String[]{path});
            }
        } else {
            ContentProviderClient contentProviderClient = getContentProviderClient();
            try {
                if (mimetypeString.startsWith("image/")) {
                    // Images
                    contentProviderClient.delete(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
                            MediaStore.Images.Media.DATA + "=?", new String[]{path});
                } else if (mimetypeString.startsWith("audio/")) {
                    // Audio
                    contentProviderClient.delete(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
                            MediaStore.Audio.Media.DATA + "=?", new String[]{path});
                } else if (mimetypeString.startsWith("video/")) {
                    // Video
                    contentProviderClient.delete(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
                            MediaStore.Video.Media.DATA + "=?", new String[]{path});
                }
            } catch (RemoteException e) {
                Log_OC.e(TAG, "Exception deleting media file in MediaStore " + e.getMessage());
            }
        }

    }