Android Question [Solved]File I/O and storage confusion.

DataMiser

Member
Licensed User
Having some issues with some file routines I am trying to add to my app.

I have this code that saves some data to a file.
B4X:
Private cfgWriter As TextWriter
cfgWriter.Initialize(File.OpenOutput(File.DirInternal,"Device.cfg",False))
cfgWriter.WriteLine(txtHostIP.text)
cfgWriter.WriteLine(txtPort.Text)
cfgWriter.close

Then I have this code that reads the file
B4X:
If File.Exists(File.DirInternal, "Device.cfg") Then
Private cfgReader As TextReader
cfgReader.Initialize(File.OpenInput(File.dirinternal,"Device.cfg"))
modCommon.HostIP=cfgReader.ReadLine
modCommon.HostPort=cfgReader.ReadLine
cfgReader.close
Else

The code is reading the data from the file but I can't seem to locate the file on the device if I browse for it from my PC.

I have added a msgbox to display the value of the folder and it shows \data\data\my.app\files. No such folder shows up in explorer. If I look under \android\data\my.app\files there is no file there.

If I switch to DirDefaultExternal or DirRootExternal it shows different paths but also paths that I can not locate on the device.

So the question is where are the files actually being written and why can't I locate them from my PC?
Also is there a way to specify some other path and/or create files that can be accessed from the PC through Windows Explorer.

I am pretty sure that when I was testing with the trial version I had used an example from the guide and the file was written under the \android\data\package,name\files folder and that I was able to see it from the pc, copy it over and look at the contents of it but for some reason I can not seem to locate either of the files being created by my app now yet I know they are being created because the app can read them afterwards.

btw I am testing using a Samsung Tab4 connected via USB to a windows 10 PC
 

DataMiser

Member
Licensed User
Pulling the USB cable and reconnecting did the trick.

Thanks

Is there a way to write to a specific folder on the device?

For example I have a Temp folder off the root is there a way to write there?
 
Upvote 0

DataMiser

Member
Licensed User
Cool, that makes sense. I suppose I was confused by what shows up when I used msgbox to display the content of File.DirRootExternal

Thanks again
 
Upvote 0
Top