Other Files (Core) - doubt

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,

Kepler
 
Last edited:

kepler

Active Member
Licensed User
Hi Don,

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

Kind regards,

Kepler
 

kepler

Active Member
Licensed User
Hi,

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?
I'm....confused...

Regards,

Kepler
 

NJDude

Expert
Licensed User
Are you sure you are looking in the right place? maybe you are mistaking DirInternal for DirDefaultInternal.
 

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...

Kepler
 

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?
 

kepler

Active Member
Licensed User
Hi,

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,

Kepler
 

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:
B4X:
If File.Exists(File.DirDefaultExternal, "options.txt") Then

...
 

pappicio

Active Member
Licensed User
wrong:
B4X:
sroot = File.DirRootExternal
filename = sroot & "/apptest/options.txt"
List1 = File.ReadList(File.DirInternal,filename )

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

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.
 

kepler

Active Member
Licensed User
Hi,

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,

Kepler
 

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"

Don't I have access to the root directory like the phone explorer app? The device is not rooted.
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"
 
Top