Android Question Files folder not synchronised on target device

Discussion in 'Android Questions' started by Bob Sabrook, May 14, 2015.

  1. Bob Sabrook

    Bob Sabrook Member Licensed User

    How do I ensure that my read-only text file (300map.txt) in my Files folder get copied to
    when I Run[for Release]?

    Initially/successfully I put the 300map.txt file in same project folder as the .b4a file,
    then, in the b4a files tab, I use the [Add Files] button, and [sync] button
    which copies it to the "Files" sub folder. (but note upper case F).

    If I manually copy the 300map.txt onto the targets Android/data/b4a.AppName/files folder my app finds it OK in File.DirDefaultExternal. So I AM looking in the right place.

    Also the AppName.APK file does NOT copy the 300map.txt to the target, at least, not on ONE attempt.

    When I run[debug(rapid)] a compressed 300map.txt DOES appear in the files/virtual_assets folder.

    I think the IDE is getting the upper/lower casing wrong for the 'files' or 'Files' folder. The IDE seems to display upper case for the first letter of some files and folders which may be cosmetic, but it is worrying and confusing. Also if I call the 300map.txt file 't300map.txt', the IDE displays it as 'T300map.txt' which is scarey because android is fussy about case, and it is not clear which name is used where.

    My B4a version is 4.30. My Android version is 4.4.4. My target device is Sony Xperia Z.

    Is the 'Files' folder supposed to be 'files' on the target.

    (Edit: Corrected; Android/data.b4a.AppName/files -> Android/data/b4a.AppName/files)
    Last edited: May 14, 2015
  2. NJDude

    NJDude Expert Licensed User

    You should include code to copy that file from our assets to the device.
    thedesolatesoul likes this.
  3. Bob Sabrook

    Bob Sabrook Member Licensed User

    Great, thanks for the hint. Any links on how to do that would be muchly appreciated :)

    (Edit: Have sorted it folks. Using
    List1 = File.ReadList(File.dirassets, "map.txt") 'correct​
    List1 = File.ReadList(File.DirDefaultExternal, "/map.txt") 'incorrect​

    many thanks. NJDude rocks!
    Last edited: May 14, 2015
  4. Erel

    Erel Administrator Staff Member Licensed User

    Make sure that the file is listed in the files tab. The IDE will automatically convert the file to lower case as it assumes that all files in the assets folder (on the device) are lower cased.
  5. Bob Sabrook

    Bob Sabrook Member Licensed User

    Thanks for Clarifying that about the case Erel. Yes I have listed the file in the files tab so that it is included in the package.
    I do NOT need to know this, but now that it works OK I am wondering where exactly on the Android target the application finds my text file because I am unable to see it anywhere with File Commander app. There is no folder called 'AssetsDir' (as returned by File.DirAssets) that I can see. and it's not in /storage/emulated/0/Android/data/b4a.AppName/files ?

    Edit: I Have also put #IgnoreWarnings:15 to suppress warning #15 that 300map is not used - when it is. Obviously there is a risk to suppressing ALL such warnings.
    Last edited: May 14, 2015
  6. Erel

    Erel Administrator Staff Member Licensed User

    You will not see this folder as it is a virtual folder mapped to the APK itself.