3 Replies Latest reply on Dec 14, 2015 3:19 AM by Ram Charan

    TC75 Android 4.4.2 : Problem with writing file on sd card

    Ram Charan

      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 and Zebra TC75

       

      Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

      intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); // set the image file name
      startActivityForResult(intent, 300);

       

      Using the above code is working and writing the image on samsung,

      but failed to write on zebra , the save button with 'tick' icon has no response.