Other Files (Core) - doubt

Discussion in 'Libraries developers questions' started by kepler, Mar 13, 2015.

  1. kepler

    kepler Active Member Licensed User

    Good morning,

    Do the procedures of the Files(core) Lib for b4a needs root permission?
    Oh, and where can I download it? :confused:

    Kind regards,

    Last edited: Mar 13, 2015
  2. DonManfred

    DonManfred Expert Licensed User

    core is installed when you install b4a

    If you want to access folders where you dont have the permissions then you need root to access this folders.
  3. kepler

    kepler Active Member Licensed User

    Hi Don,

    Sorry....I was just realizing that in the documentation.
    I apologise for the ignorance... :(

    Kind regards,

  4. kepler

    kepler Active Member Licensed User


    Since we're on the subject, does anyone knows how to find a particular file in the internal phone storage?

    I've tryed something like this:

    If File.Exists(File.DirInternal, "options.txt") Then
    List1 = File.ReadList(File.DirInternal, "options.txt")
    ... (etc)
    If List1.Size<1 Then Msgbox("nothing found...","Info")

    I always get nothing found... But the file is there!!! Is it the path that must be defined? Which path?


  5. NJDude

    NJDude Expert Licensed User

    Are you sure you are looking in the right place? maybe you are mistaking DirInternal for DirDefaultInternal.
  6. kepler

    kepler Active Member Licensed User

    Hi NJDude,

    Actually I don't know... DirDefaultInternal does not appear as an option actually.

    The file is located in the internal storage of the phone, in a folder called apptest

    So, I'm trying

    List1 = File.ReadList(File.DirInternal, "/apptest/options.txt")

    I also tried to retrieve first the root, and:

    sroot = File.DirRootExternal
    filename = sroot & "/apptest/options.txt"
    List1 = File.ReadList(File.DirInternal,filename )

    Something is missing...

  7. NJDude

    NJDude Expert Licensed User

    There's your confusion, DirRootExternal and DirDefaultExternal points to the internal SD Card, DirInternal is accessible just to your app, my question is, where and how are you creating that "options.txt" file, can you post the code?
  8. kepler

    kepler Active Member Licensed User


    I'm very sorry to bother you like this.
    I've placed the mentioned file in the internal storage - in the folder apptest - of the cell phone; I copied it from my computer to the internal storage.
    Now I'm trying to retrieve it using B4A.
    Do you have any idea how to do this?
    I sure ain't....

    Kind regards,

  9. NJDude

    NJDude Expert Licensed User

    You are using the SD Card, so, DirInternal is wrong, like I said, DirInternal is only visible to your app.

    To fix you code you have to use:
    If File.Exists(File.DirDefaultExternal, "options.txt"Then

  10. pappicio

    pappicio Active Member Licensed User

    sroot = File.DirRootExternal
    filename = sroot & 
    List1 = 
    File.ReadList(File.DirInternal,filename )

    change to:
    sroot = File.DirRootExternal
    filename = 
    log(sroot & "/" & filename) 'just to see if you'll have: "/sd-card/apptest/options.txt"
    List1 = File.ReadList(sroot ,filename )
  11. NJDude

    NJDude Expert Licensed User

    Note that is recommended to use DirDefaultExternal instead of DirRootExternal, the reason for that is because when/if the app is uninstalled all files created by the app should be also removed, if the files are created on DirRootExternal they will remain, taking unnecessary space on the device.
  12. kepler

    kepler Active Member Licensed User


    I think what the problem is so far....Everyone's right - and everyone's wrong (specially me).

    I created the apptest folder in the internal storage root - and placed the options.txt file there. I did it manually with the explorer of the cell phone.
    That would bring the file path as storage/emulated/0/apptest/options.txt

    The reason I can't reach this file, is because the script is searching for it in my b4a app files: storage/emulated/0/Android/data/my.script/files/apptest/options.txt

    Don't I have access to the root directory like the phone explorer app? The device is not rooted.

    Any sugestion? I would glady like one.... :(

    Kind regards,

  13. Mahares

    Mahares Well Known Member Licensed User

    storage/emulated/0/Android/data/my.script/files/apptest/options.txt is equivalent to
    File.DirDefaultExternal & "/apptest/options.txt"

    Yes, You can create a folder in the root of the internal SD card called apptest then the text file will be referred to like this:
    File.DirRootExternal & "/apptest/options.txt"
  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