do you have something like
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="18" />
in your androidmanifest.xml ?
http://developer.android.com/guide/topics/manifest/uses-permission-element.html
http://developer.android.com/reference/android/Manifest.permission.html
On Wed, Dec 9, 2015 at 10:43 PM, Dinesh Balu <[email protected]> wrote:
> Hi,
> I'm trying to write on removable storage , But getting IOException
>
> java.io.FileNotFoundException:
> /storage/extSdCard/PWC/Images/IMG_20151210_113150.jpg: open failed: EACCES
> (Permission denied)
> at libcore.io.IoBridge.open(IoBridge.java:409)
>
> Caused by: libcore.io.ErrnoException: open failed: EACCES (Permission
> denied)
> at libcore.io.Posix.open(Native Method)
> at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
> at libcore.io.IoBridge.open(IoBridge.java:393)
>
> The line I used to write is
>
> try{
>
> FileInputStream myinput = new FileInputStream(from);
>
> String outfilename = to;
>
> OutputStream myoutput = new FileOutputStream(outfilename);
> // transfer byte to inputfile to outputfile
> byte[] buffer = new byte[1024];
> int length;
> while ((length = myinput.read(buffer)) > 0) {
> myoutput.write(buffer, 0, length);
> }
>
> //Close the streams
> myoutput.flush();
> myoutput.close();
> myinput.close();
>
> return true;
> }
> catch ( IOException e){
> e.printStackTrace();
> return false;
> }
>
> from and to is a valid file location.
>
> If I use Internal and Emulated External file path , Above is working fine.
> If I use secondary or removable storage file path , getting issue.
>
> The path gives canWrite as true.
>
> Testing on Android 4.4.2 Samsung SM-G350E
>
> --
> You received this message because you are subscribed to the Google Groups
> "Android Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/android-developers.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/android-developers/43d0467c-9c45-407c-a990-7941bfbd89a2%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/android-developers.
To view this discussion on the web visit
https://groups.google.com/d/msgid/android-developers/CAA2GJqUvYm0rFnWvPsbiHZBnBh0DcatgqfW1-a2UpMo6Z1bg%3DQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.