tool-suite-X icon indicating copy to clipboard operation
tool-suite-X copied to clipboard

Incomplete deletion of instances

Open linl33 opened this issue 6 years ago • 2 comments

Software and hardware versions

Survey 2.0.5, Tables 2.0.5, Services 2.0.5

Problem description

When images, videos, recordings, or signatures are added through Survey, that attachment is recorded to a content provider. This record doesn't get deleted when the instance is deleted.

Steps to reproduce the problem

  1. Open Example Form (or any form with attachment) in Survey
  2. Capture a photo or choose an image
  3. Finalize
  4. Delete that instance from either Survey, Tables, or Services
  5. Browse the content provider, for example through Survey's Choose Image, and notice the deleted instance.

Expected behavior

Attachment record gets deleted when the instance is deleted. Alternatively, never put attachment records in the content provider.

Other information

We have 3 activities (MediaDelete*Activity) in Survey they handle removing records from the content provider but they are being called.

Relevant snippet MediaChooseImageActivity.java#L166-L175

      // Add the new image to the Media content provider so that the
      // viewing is fast in Android 2.0+
      ContentValues values = new ContentValues(6);
      values.put(Images.Media.TITLE, newMedia.getName());
      values.put(Images.Media.DISPLAY_NAME, newMedia.getName());
      values.put(Images.Media.DATE_TAKEN, System.currentTimeMillis());
      values.put(Images.Media.MIME_TYPE, MEDIA_CLASS + extension.substring(1));
      values.put(Images.Media.DATA, newMedia.getAbsolutePath());


      mediaURI = getContentResolver().insert(Images.Media.EXTERNAL_CONTENT_URI, values);

linl33 avatar Sep 06 '18 02:09 linl33