I am trying to implement the best practices described in Loading Bitmaps effeciently
I've run into trouble because this line:
Utils.getExternalCacheDir(context)
inside of DiskLruCache.java is returning null, which means I get NullPointerException
when I try to call .getPath()
Despite the somewhat cryptic NullPointerException
that gets thrown the actual issues is that my application did not have WRITE_EXTERNAL permission, so the system was rejecting my attempt to use the ExternalDir for caching. Unfortunately this was happening at a low enough level in the code used in Displaying Bitmaps Effeciently that the Exception does not indicate SecurityException
as it normally would if one were trying to write to the SD card without the proper permission.
To fix simply add this:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
to your manifest.
This can also happen if you're running on a device or emulator without any external storage.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With