Where to save pictures on Android?

前端 未结 5 2081
被撕碎了的回忆
被撕碎了的回忆 2020-12-22 23:06

My application uses quite a lot of pictures that are downloaded from the internet and cached locally on the Android phone. I am wondering, what is the correct way to save th

5条回答
  •  佛祖请我去吃肉
    2020-12-22 23:36

    I think the best way is to use the database.

    1. It does not blow up the application and memory.
    2. The related database is deleted once the application is uninstalled.
    3. Nobody can reach to this files besides your application.

    Update: But; If you want to cache only the data, there is a cache manager defined in webkit. CacheManager

    I didn't use the package before but the methods seem straight forward to use:

    static boolean   cacheDisabled()
    static boolean   endCacheTransaction()
    static CacheManager.CacheResult  getCacheFile(String url, Map headers)
    static File  getCacheFileBaseDir()
    static void  saveCacheFile(String url, CacheManager.CacheResult cacheRet)
    static boolean   startCacheTransaction()
    

    and you can find the usage at Google Gears code

    I hope this helps.

提交回复
热议问题