I am trying to load .gif image from external storage (pictures directory) but I am getting 'file not found exception' using the following code.
InputStream mInputStream = null;
AssetManager assetManager = getResources().getAssets();
try {
mInputStream = assetManager.open(getExternalFilesDir(Environment.DIRECTORY_PICTURES).getAbsolutePath().concat("/01.gif"));
} catch (IOException e) {
e.printStackTrace();
}
I have also tested using manually path but got same exception
mInputStream = assetManager.open("file:///mnt/sdcard/Android/data/com.shurjo.downloader/files/Pictures/01.gif");
There is a write/read permission from the SD card in menifest file
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Please help me how can I open a file as InputStream from external storage. Thanks in advance.
Note: I have tested it on emulator and there is a file 01.gif under Pictures folder (please see manual path). I can create directories and put files in those directories but can not able to access those files though Input Stream.