Save image to sdcard from imageview

十年热恋 提交于 2019-12-11 18:45:57

问题


I have listview having customized some textview and one imageview. When I long click on item I have store that item information to the database but the question is how to store image in sdcard and store the relevant path to the database. The image alread download as cache now I don't want to re-download that image.

Is there way to store that Image to the sdcard.

I am using this example to download the images for listview https://github.com/thest1/LazyList

Edit I got solution

no need to extra process when using this example. Just store the web path of image into the database and pass that imageview into the ImageLoader object with path it'll use the cache images if the image was exist for same URL


回答1:


No Need to extra process, Using this example it'll will care for future usage also for same URL of image. This will get from the cache directory if the image found that use that image otherwise download it and then use it.




回答2:


If you use Prime the caching will be transparent, when you request the image again it will grab it from a memory cache if available or a disk cache automatically. It also is really easy to get images with.




回答3:


You can save your bitmap which you get via Bitmap bitmap=memoryCache.get(url); using save-file-to-sd-card.


You can also get the bitmap from the ImageView(if you want) like:

//say your ImageView object is i;
i = (ImageView) findViewById(R.id.img);
Drawable d = i.getBackground();
Bitmap bitmap = ((BitmapDrawable)d).getBitmap();


来源:https://stackoverflow.com/questions/10900893/save-image-to-sdcard-from-imageview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!