Using the following code to load a jpg into a bitmap and draw it on a canvas
File extStore = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
File myFile = new File(extStore.getAbsolutePath() + "/MyPicture.jpg");
if(myFile.exists()){
Toast.makeText(getBaseContext(),"yes",Toast.LENGTH_LONG).show();
}
Bitmap b1 = BitmapFactory.decodeFile(myFile.toString());
canvas.drawBitmap (b1, 0, 0, null);
The App crashes with 2 errors
BitmapFactory: Unable to decode stream: java.io.FileNotFoundException: /storage/emulated/0/Pictures/MyPicture.jpg: open failed: EACCES (Permission denied)
and further down it says
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.isRecycled()' on a null object reference
I have permissions set in manaifest as follows
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
App is targeting API 19 so shouldnt matter
The check to see if the file exist works so it is the correct location
It just wont work any ideas where im going wrong
Thanks in advance
Mark