Android Question EACCES (Permission denied)

Discussion in 'Android Questions' started by prokli, Mar 9, 2015.

  1. prokli

    prokli Active Member Licensed User

    When running my app in release mode I get this error message:
    java.io.FileNotFoundException: /mnt/sdcard/AMF/test.txt: open failed: EACCES (Permission denied)

    The Folder and file exists. If I rund this small app in debug mode, I do not get this error. How funny!?

    I know that Google has changed acceess rights when writing to external card but this is the internal card.
    When I open ES file Explorer I can create and delte files in this Directory

    Can someone please help!!!!!
    Thx
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Don't hardcode to path to the "sdcard". It will be different on other devices.

    Use File.DirRootExternal. As a bonus it will add the required permission for you.
     
    thedesolatesoul and DonManfred like this.
  3. prokli

    prokli Active Member Licensed User

    Thanks!
    My app works fine using this approach.
    I seems that "File.DirRootExternal" is a part of the internal memory card which is emulated as being an
    external Card. Right?
     
  4. DonManfred

    DonManfred Expert Licensed User

    Right

    As @Erel already stated: the Path to the REAL External SdCard can differ from model to model.
    If you are using Android 5+ then you can use this library to find out the path to the (2nd) external SdCard. There is a codesnippet in the forum to find all paths. Probably your External Sd too.
     
    Last edited: Mar 10, 2015
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice