Magnus2005
Magnus2005

Reputation: 97

Android: Where and how to store images in app?

I have a problem with storing avatars. My app got user's detail with image (image is in byte[] array). How to store this images in my app? I mean should I save every user's image in internal or external storage? Or should I use this image in time and set as ImageView? What is best solution for my problem?

Thanks for help:)

Upvotes: 4

Views: 6318

Answers (2)

Seagull
Seagull

Reputation: 1133

There are advantages and disadvantages in storing images in internal storage. It also largely depends on your apps' business logic. In the android documentation here it is explained very well.

Internal storage:

  1. It's always available.

  2. Files saved here are accessible by only your app.

  3. When the user uninstalls your app, the system removes all your app's files from internal storage.

External storage:

  1. It's not always available, because the user can mount the external storage as USB storage and in some cases remove it from the device.

  2. It's world-readable, so files saved here may be read outside of your control. When the user uninstalls your app, the system removes your app's files from here only if you save them in the directory from getExternalFilesDir().

Upvotes: 3

Nilesh Senta
Nilesh Senta

Reputation: 5462

First convert byte array into Bitmap

Bitmap bitmap = BitmapFactory.decodeByteArray(bitmapdata , 0, bitmapdata .length);

And store bitmap into external storage as file

Convert Bitmap to File

Upvotes: 0

Related Questions