Rahul
Rahul

Reputation: 1423

caching images/file in android for listview

I have a listview with title and image in one row. And image is to come from remote server. Whats the best way to cache those images in android. I could think of two ways.

  1. Cache image on sdcard and corresponding entry in sqlite so that I can get path while listview is being scrolled.

  2. Cache images per activity so if activity finishes. Image cache flushes

Point 2 is simpler but not efficient.

How will be the performance in point 1.

Please help and suggest any other alternatives.

Upvotes: 0

Views: 8343

Answers (1)

Valter Júnior
Valter Júnior

Reputation: 948

The answer is: it depends. You need to know if the application is going to access files on web every time you open an activity, and you need to know if the server images change frequently or not.

I think option 1 is a good option if images don't change frequently, and option 2 is a good option if images change frequently.

For more information, read this: http://developer.android.com/training/displaying-bitmaps/index.html

Upvotes: 3

Related Questions