Take the 2-minute tour ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

I'm attempting to write a script to test out a camera for long periods of time, and one of the issues right now is the fact that it runs out of space when pictures are taken. My initial approach is to remove the picture using adb after its taken. The issue is, even after I remove it from the location it is saved in, it remains visible in the gallery, and I assume it's taking up space somewhere. The properties associated with it (such as width, height, flash info, etc) all get deleted as well, except for the size.

What I'm currently doing is deleting all files in the DCIM directory (where the camera saves the pictures) after every time a picture is taken, using adb. Additionally, when I search throughout the phone using adb, I cannot find anything similar to the pictures anywhere in the file structure.

Is it possible to fully delete the pictures using adb? Is there a cache where the images are stored somewhere? The only way I can get the pictures to fully be removed from the phone are to either reboot, or use monkey runner to delete the pictures through simulated touches in gallery (which is tedious for a large # of photos).

share|improve this question
    
Check the accepted answer in This Question for an alternative to mount/unmount manually –  FoamyGuy Jul 7 '12 at 2:31
add comment

3 Answers 3

up vote 1 down vote accepted

The reason the pictures remains visible in the Gallery is because the Android's MediaScanner is a bit weak in this regard. What happens is this - when Android boots up, it runs the MediaScanner, which goes off and checks all the images, ringtones, audio to sum up, and keeps tab on it. This is only done once on boot.

You can get around this, by unmounting the SD Card, do this safely (Settings > Storage > Unmount SD Card) this will take a few seconds, once its unmounted, you can pop out the SD Card, pop it back in again, this in turn will force the MediaScanner to run again, and then all the images that you've deleted are no longer there in the Gallery.

MediaScanner is a service that acts as a caching service in that it caches all media (images/audio). On some ROMs, there is a facility to force it to run again without having to do the above.

share|improve this answer
add comment

Try the proposed solutions in this post. In short, one of these may trigger media scan:

  1. Send a broadcast Intent ACTION_MEDIA_MOUNTED. Note that it's possible to send an intent via ./adb shell am.
  2. Run the Rescan Media app
  3. Renaming a file
  4. Taking a photo through the Camera app
  5. Remounting SD Card
  6. Rebooting
share|improve this answer
    
Unfortunately, 2-5 don't work for me, at least on ICS. I'm trying 1 now, but judging by the fact that 5 didn't work, I don't have high hopes for it. –  nocley Jul 9 '12 at 16:05
add comment

While other answers have given nice workarounds for this issue, most of them seem to not work properly in ICS. The only sure method of deleting all pictures was as such:

  1. Delete all files in DCIM Folder
  2. Clear Data for Gallery
  3. Clear Data for Media Storage
  4. Kill both Gallery and android.process.media

I've attempted to get these into a script, the issue is with 3 - as Media Storage doesn't give it's process name, and as such I can't clear data through 'adb shell pm clear processname' for it.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.