Back to project page Resonos-Android-Framework.
The source code is released under:
Apache License
If you think the Android project Resonos-Android-Framework listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.resonos.apps.library.file; //from w w w . j a v a 2s .c o m import java.io.File; import java.net.URLEncoder; import com.resonos.apps.library.App; /** * Class that implements a file cache of bitmaps. * From LazyList at https://github.com/thest1/LazyList/ */ public class FileCache { private File cacheDir; public FileCache(App app) { // Find the dir to save cached images if (android.os.Environment.getExternalStorageState().equals( android.os.Environment.MEDIA_MOUNTED)) cacheDir = new File( android.os.Environment.getExternalStorageDirectory(), "Android/data/" + app.getContext().getPackageName() + "/cache/"); else cacheDir = app.getContext().getCacheDir(); if (!cacheDir.exists()) cacheDir.mkdirs(); } @SuppressWarnings("deprecation") public File getFile(String url) { String filename = URLEncoder.encode(url); File f = new File(cacheDir, filename); return f; } public void clear() { File[] files = cacheDir.listFiles(); if (files == null) return; for (File f : files) f.delete(); } }