1

My app is a photo app. I need to use user's photos (storing on the 'virtual' sdcard or the real sdcard) to turn to a thumbnail and display them. If the user click on a thumbnail I will display the full-size photo (which I load from its real location). If some time later the user deletes the photo, then my app just has the thumbnail but cannot display the real photo.

If I copy original photos to my app location or a specific folder, than it's a duplication. My app uses a lot of photos, so it will be unsustainable (later the user get annoyed because of the storage hogging and may delete the app). That's why I don't copy the originals, but grab them from their real locations

The question: Is there a way that I register to the OS that the files the users want to delete are needed by my app and they can't delete them? (By googling around, it seems impossible, but who knows, worth a try)

Thanks

EyeQ Tech
  • 7,198
  • 18
  • 72
  • 126
  • Why dont you just poll the Photo DB at the strike of 12 each night ( Using a service which runs in the background) to update your files list? – Skynet Jan 19 '14 at 09:22

1 Answers1

1

Isn't the reason I delete a picture that I don't want to see it again? No matter what you're doing within your app, you shouldn't make this kind of restriction.

Either copy the pictures and deal with the double amount of used memory (which still doesn't mean that the user can't remove these files... they're still visible to him) or use the pictures that are currently on the disk, without taking care of deleted ones.

To answer your question: It's not possible to entirely restrict the deletement of pictures. It might be possible if you have root-access, but even there I'm not sure how you would restrict writing/modifying/deleting of pictures when the user can easily put the sd-card into the computer.

There might be a way to set the files to read-only (memory storage only). Have a look in:

How do we copy files and retain their read only attribute in Android?

Attempt to create an readonly file on the android SD card fails

Anyway, even if you find a way to deal with this problem -> You should not! Let the user decide what he wants to delete!

Edit: Another approach would be to implement a FileObserver. Listen to the picture-folder and in case a file is removed, copy this single file. Unfortunately the observer will simply tell you what's already happened ;)

(see How do you implement a FileObserver from an Android Service).

Community
  • 1
  • 1
Frame91
  • 3,670
  • 8
  • 45
  • 89
  • 1
    "Isn't the reason I delete a picture that I don't want to see it again", no, user can accidentally delete it. – EyeQ Tech Jan 19 '14 at 08:38
  • Dropbox, SkyDrive, GoogleDrive and other CloudComputing-Platforms could save these files vor you. Anyway I updated my answer with another approach – Frame91 Jan 19 '14 at 08:41