Android Question writing to a file

DPaul

Active Member
Licensed User
Longtime User
Hi,

I have always received clear answers to my b4a newbie questions.
Except this one.
I seem to be able to write to a file without errors / bugs:
File.WriteList(File.DirInternal, "List.txt", listEvents).
I can also msgbox() to find out whereabouts the file.DirInternal is:
"/data/data/b4a.example/files" ....?
"List.txt" is nowhere to be found on the tablet.
I thought i had to download a more performant file viewer,
but none seems to do the job.
Which one could solve my problem?

Thanks
Paul
 

bgsoft

Well-Known Member
Licensed User
Longtime User
Hi:

File.DirInternal is read-only - Sorry I correct it, is write / read

Regards
 
Last edited:
Upvote 0

DPaul

Active Member
Licensed User
Longtime User
Better write app data to private File.DirDefaultExternal , you will find it under android/data/"app id" ... It will be deleted in case of uninistall...

Thanks, but i do not want to write to any sd card. I cannot guarantee that there is one.

I also do not see /data/"app id"... anywhere..

?
Paul
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
If you start typing the file.dir command, you will see the options available and with them a short description of what they are or do...
Since I am on my phone I cannot precisely point you the command, but I think you have an appData folder anywhere that points to a private folder that gets created when your app is installed
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
File.DirInternal is read-only
No, File.DirInternal is write / read.
File.DirAssets is read-only.
If you use the file only with your application you shouls use File.DirInternal. You won't see this folder on your device, only your program can access it.
If you need the file with any other program I suggest to use File.DirRootExternal with a subdirectory. With this you can also access the file from the PC with a USB connection.
 
Upvote 0

bgsoft

Well-Known Member
Licensed User
Longtime User
No, File.DirInternal is write / read.
File.DirAssets is read-only.
If you use the file only with your application you shouls use File.DirInternal. You won't see this folder on your device, only your program can access it.
If you need the file with any other program I suggest to use File.DirRootExternal with a subdirectory. With this you can also access the file from the PC with a USB connection.

Yes, you're right, I read very quickly the post and mistook File.DirAssets :oops:

Regards
 
Last edited:
Upvote 0

DPaul

Active Member
Licensed User
Longtime User
Dear folks,
I appreciate your help, but there must be some android thing that is "spooky".
(Remember, i do NOT want to write to any sd card)
I now have tried many times to write to "file.dirinternal", with and without a (file.dirinternal & "/test/", ...) destination.
The system comes back to say that "/test/" does not exist, and neither does the file "List.txt" that i am trying to write.
The program aborts at that line.
BUT !
It did create, all by itself, the "/test/" subdir here : This PC\GT-P7500\Tablet\Android\data\b4a.example\files\test
AND !
To trick the system , i put an dummy "List.txt" into te subdir "test". The system still says that these things are NOT there:
BUT!
When i open "List.txt" it is still empty and it calls itself List(1).txt or List(2).txt, implying that there are others, invisible ?
AND, icing on the cake, !
In one of the old tests, unfortunately i cannot recreate it, it DID create a visible "List.txt" with the desired content (before the test subdir).
Weeks ago, i also observed that every once in a while the output text shows up. (Each time i close the program it writes the text-file without me testing for it.)
How hard can it be, to write to a simple text file? (and retrieve it) :)
 
Upvote 0

bgsoft

Well-Known Member
Licensed User
Longtime User
It did create, all by itself, the "/test/" subdir here : This PC\GT-P7500\Tablet\Android\data\b4a.example\files\test

File.DirInternal it's not in : Android\data\
It's i: data/data
Write this and you'll know where it is:
B4X:
Log("File.DirInternal " & File.DirInternal)



Regards
 
Upvote 0

DPaul

Active Member
Licensed User
Longtime User
File.DirInternal it's not in : Android\data\
It's i: data/data
Write this and you'll know where it is:
B4X:
Log("File.DirInternal " & File.DirInternal)
Regards

Thanks,
It says : File.DirInternal /data/data/b4a.example/files
When i examine my tablet through USB or the standard file manager, i see NO data/data....dir anywhere

i tried to create one in the root, next to the adroid dir, it lets me do that.
But writes nothing inside when tested!
?
 
Upvote 0

DPaul

Active Member
Licensed User
Longtime User
That's true. Only your app can access File.DirInternal.

OK, what about, i want to write to a file (Not on any sd card.), and then pick it up to:
a) Attach it to an email
or b) upload it to a site
or c) pick it up and move it to my pc.
Is that impossible ?
Seems pretty straightforward to me :)
How do i make it visible?
 
Upvote 0
Top