tool-suite-X
tool-suite-X copied to clipboard
Incomplete deletion of instances
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
- Open Example Form (or any form with attachment) in Survey
- Capture a photo or choose an image
- Finalize
- Delete that instance from either Survey, Tables, or Services
- 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);