Skip to content
This repository has been archived by the owner on Oct 15, 2018. It is now read-only.

Commit

Permalink
[sample] Only use external storage for disk cache if it's usable.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Banes committed Feb 21, 2013
1 parent b34e45b commit 1fc2ede
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions sample/src/uk/co/senab/bitmapcache/samples/SampleApplication.java
Expand Up @@ -31,8 +31,16 @@ public class SampleApplication extends Application {
public void onCreate() {
super.onCreate();

File cacheLocation = new File(
Environment.getExternalStorageDirectory() + "/Android-BitmapCache");
File cacheLocation;

// If we have external storage use it for the disk cache. Otherwise we use
// the cache dir
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
cacheLocation = new File(
Environment.getExternalStorageDirectory() + "/Android-BitmapCache");
} else {
cacheLocation = new File(getFilesDir() + "/Android-BitmapCache");
}
cacheLocation.mkdirs();

BitmapLruCache.Builder builder = new BitmapLruCache.Builder();
Expand Down

0 comments on commit 1fc2ede

Please sign in to comment.