简体   繁体   中英

I need to store 154 images for my android app, what is the best way to do this?

I am making an android app which will need to display images for each item in a database which is currently 154 records long.

Now if I put the images into the database I would still have to store them in the resources to insert them when the app is first downloaded, I want to store this database locally on the app as the records are not likely to change and if the user doesn't have access to the internet they can still display some information.

Basically, I am wondering if storing these images in the local resources is the best way to go about it as having 154 images stored locally seems like a lot.

If you do care for apk size then do not put these images static . Instead you can keep these images on server (your or free server) and easily load those images using libraries like Glide or Picasso .

If you think apk size will doesn't matter for you and user should not face problem due to unavailability of internet then you can keep those images static inside app iteself.

here the best example with glide library.. i hope it might help

http://www.androidhive.info/2016/04/android-glide-image-library-building-image-gallery-app/

and for the apk size you can shrink image app easily with progurd

When designing an app that stores images and cache it for later used, I will not think of how many images in my server are, but I will think how much is my current phone capacity . Is it enough? Do I need to do some compression?

Here are some of basic guides upon building. Note : these key points are intended only for simple app architecture since discussing a complex app architecture might need a longer answer format.

  1. Check if SD card is mounted. Note: I know you can store images through phone default storage but as much as possible don't use it because it is reserve for the OS.

  2. Before storing the image query first its size and compare to the phone's current memory if(image.size <= phoneMem) save() else discard() . You can also check about StatFS usage.

  3. If you feel that you wanted to store more images then use any Image compression algorithm. You can find many of those like Lossess Compression .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM