Android Question File permission problem - cannot read file

Discussion in 'Android Questions' started by barryhuntpinncomp, May 9, 2018.

  1. barryhuntpinncomp

    barryhuntpinncomp Member Licensed User

    Until recently my program has been able to write and read a particular file. For no apparent reason the file cannot be read at present. I get
    java.io.FileNotFoundException: /storage/emulated/0/BarryWalk/rates.txt (Permission denied)

    File.exists returns true.

    The file can be read by a different program on the same device. The two program's manifest are identical.
    They both contain
    AddPermission(android.permission.WRITE_MEDIA_STORAGE)
    AddPermission(android.permission.WRITE_EXTERNAL_STORAGE)

    I cannot think of any other settings.

    Any help would be much appreciated.
     
  2. ronell

    ronell Well-Known Member Licensed User

    does the 2 device had the same os/android version?
     
  3. barryhuntpinncomp

    barryhuntpinncomp Member Licensed User

    There is only one device running two programs. Both programs have the identical read statement.
    l= File.ReadString(File.DirRootExternal, "/BarryWalk/rates.txt")
    One works and the other does not
     
  4. DonManfred

    DonManfred Expert Licensed User

  5. barryhuntpinncomp

    barryhuntpinncomp Member Licensed User

    Thank you for the link.
    When I add the module Runtimepermissions (without any extra coding) I get a compile error.
    Maven artifact not found: android.arch.lifecycle/livedata-core
     
  6. ronell

    ronell Well-Known Member Licensed User

    sorry, misread :confused:
     
  7. ronell

    ronell Well-Known Member Licensed User

    DonManfred likes this.
  8. barryhuntpinncomp

    barryhuntpinncomp Member Licensed User

    OK, great thank you.

    I have now added the "RunPermission" library but I am struggling as to how it should be used.

    I tried
    rp.CheckAndRequest("PERMISSION_READ_EXTERNAL_STORAGE")
    Log(rp.Check ("PERMISSION_READ_EXTERNAL_STORAGE")) - it returned false but I admit to being out of my depth.
     
  9. DonManfred

    DonManfred Expert Licensed User

    See Runtimepermission Tutorial.....
     
  10. barryhuntpinncomp

    barryhuntpinncomp Member Licensed User

    OK, thank you for your help and patience. It is very much appreciated.
     
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