Reputation: 41779
Android internal or external cache directory is nicely explained on android's blog but they do not say much about what data should be saved internally and what externally.
Or to be honest, they say that private data is saved internally, and public data externally.
Can you name some examples of what I should save internally and what externally?! The private data term confuses me more than public data term.
Upvotes: 0
Views: 627
Reputation: 51581
Think of private data as being what's essential to the workings of your app.
Consider a simple file manager that has the functionality of letting users favorite
files and folders. Of course, you could save this information using a database or SharedPreferences, but for argument sake, let's say you decide on a data structure to store it. This is something you'd write to internal
storage to keep it from being deleted accidentally by the user(or perhaps, by another app?).
Another example: Say, you let the user decide on a gallery image as their avatar inside your app. One way is to store the image path, scale and load it on every app launch. This would work as long as the image stays at the same path (isn't deleted or moved or renamed). Another option is to scale the image, write it to internal storage, and load it on successive launches.
Everything that I wouldn't mind losing goes to external storage. Say, my app downloads an image file on user request. I would save it to external storage. If the user deletes it, I can always grab it again.
Upvotes: 1