Removing inserted ContentValues

I created custom intents for the user to select photos or take a picture.

Here's my code:

Intent pickIntent = new Intent(Intent.ACTION_PICK, 
        MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
pickIntent.setType("image/*");


values = new ContentValues();
values.put(MediaStore.Images.Media.TITLE, "new image");
values.put(MediaStore.Images.Media.DESCRIPTION, "saved today");

Intent takePhotoIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
cameraPhotoUri = getContentResolver().insert(
        MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
takePhotoIntent.putExtra(MediaStore.EXTRA_OUTPUT, cameraPhotoUri);



String pickTitle = "Select or take a new Picture"; // Or get from strings.xml
Intent chooserIntent = Intent.createChooser(pickIntent, pickTitle);
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, 
        new Intent[]{takePhotoIntent});

startActivityForResult(chooserIntent, REQUEST_CODE_ADD_PHOTO);

      

now the part getContentResolver().insert(...)

creates an empty file in the image directory. How to remove all of them (empty files) after using intents. Please, help.

+3


source to share





All Articles