Android Question How to write or delete files on external sd with KITKAT

Discussion in 'Android Questions' started by cb56, Feb 7, 2014.

  1. cb56

    cb56 Member Licensed User

    Hi,
    with KITKAT seems that non-system app can't write to external sd card.

    Using "File.Copy" I get this error: libcore.io.ErrnoException: open failed: EACCES (Permission denied)

    I noticed for example that the developer of QuickPic (the famous app to view images) in the latest release has solved the problem.

    Is there any solution with b4a?

    Thanks
     
  2. eps

    eps Well-Known Member Licensed User

    Really? What directory are you attempting to access?
     
  3. DonManfred

    DonManfred Expert Licensed User

    I have KitKat and i´m able to save files to File.DirRootExternal without problems...
     
  4. cb56

    cb56 Member Licensed User

    Any directory of External SD; if you search in Google is a known issue.
     
  5. cb56

    cb56 Member Licensed User

    DirRootExternal points to the INTERNAL SDCard
     
  6. stevel05

    stevel05 Expert Licensed User

    I haven't noticed that problem, what filepaths are you copying from and to?
     
  7. cb56

    cb56 Member Licensed User

    From: any folder of internal sd
    destination: /mnt/extSdCard/AnyDir

    on Galaxy Note3

    Worked perfectly before upgrading to KITKAT
     
  8. stevel05

    stevel05 Expert Licensed User

    Just did a test using:

    Code:
    File.Copy("/storage/sdcard0/","sign.png","/storage/sdcard0/","sign1.png")
    And it worked.

    My File.DirRootExternal reports /storage/emulated/0
     
    Vahid.m likes this.
  9. stevel05

    stevel05 Expert Licensed User

    Have you checked that the name hasn't changed with a file manager? I know it shouldn't but.......
     
  10. cb56

    cb56 Member Licensed User

    My File.DirRootExternal reports /storage/emulated/0 too, but is INTERNAL SD

    /storage/sdcard0 is INTERNAL SD

    Is a known issue, look here: http://forum.xda-developers.com/showthread.php?t=2617921

    I've Seen this solution, anyone can convert it in B4A?: http://forum.xda-developers.com/showthread.php?t=2634840

    EDIT: I've found another problem with KITKAT: "File.Delete" does not delete the files on the external sd card and do not raise error!

    The workaround for now is to use "If File.Exists" even after attempting to delete...

    This should be solved...
     
    Last edited: Feb 7, 2014
    krizick likes this.
  11. cb56

    cb56 Member Licensed User

    Any solution?
     
  12. Erel

    Erel Administrator Staff Member Licensed User

    There is nothing to solve or that can be solved. It is explained here: http://source.android.com/devices/tech/storage/index.html

    If you want to write to a removable external card then you can only write to a folder based on your package name.

    File.DirRootExternal / DirDefaultExternal continue to work properly.
     
    merlin2049er likes this.
  13. cb56

    cb56 Member Licensed User

    Thanks Erel,
    this is a huge problem in KITKAT.

    I'll try to ask the developer of QuickPic because I assure you that, in the latest release, QuickPic writes correctly in any folder on the external sd with KITKAT.

    Nonetheless, "File.Delete" do not delete files and do not raise any error when you try to delete files on External sd, maybe this should be fixed.

    cb56
     
    krizick likes this.
  14. Erel

    Erel Administrator Staff Member Licensed User

    File.Delete returns True if the file was successfully deleted. You should check the return value.

    File.Delete implementation:
    Code:
    public static boolean Delete(String Dir, String FileName) {
         
    return new java.io.File(Dir, FileName).delete();
       
    }
    As you can see it just calls the native API. If the native API fails then there is nothing that can be done.
     
    Theera and eps like this.
  15. Paulsche

    Paulsche Well-Known Member Licensed User

    Are there plans to solve the problem in B4A?
    Users ask for a solution in order to continue backing up to ext.SDcard from my APPs. I do not know what I can answer.
     
  16. Erel

    Erel Administrator Staff Member Licensed User

  17. Paulsche

    Paulsche Well-Known Member Licensed User

    Thanks Erel,

    I have already read, but has been adapted to other APPs that the writing on ext.SDcard working again, so it must be a way
    or do I see this wrong?
    How can I prevent that user a path of ext.SDcard as a backup path choose? Currently, you can always get an error.
     
  18. Erel

    Erel Administrator Staff Member Licensed User

    Last edited: Mar 3, 2014
  19. Paulsche

    Paulsche Well-Known Member Licensed User

  20. cmweb

    cmweb Active Member Licensed User

    Hi Erel,

    it seems that some developers have managed to workaround this restriction. For example, Total Commander file manager fixed the problem with writing to external SD card in the latest beta version of the app:

    http://www.ghisler.com/android.htm

    So, maybe we can also have a solution for this serious problem?

    Best regards,

    Carsten
     
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