Random Access File or similiar

anaylor01

Well-Known Member
Licensed User
Longtime User
I have a file open dialog box. When the user select the file I want to display the contents in a label one row at a time based on a timer. I have tried using RandomAccessFile but am having problems. I have a file stored on the the Emulator SDCARD but when I select the file it keeps telling me that it doesn't exist.
B4X:
fdlg.Show("Load File","Load File","Cancel","",Null)
Dim fle As String
fle = fdlg.FilePath
lblfilename.text = fle & "/" & fdlg.ChosenName
Dim raf As RandomAccessFile
raf.Initialize(File.l, lblfilename.text, False) 
lblfilename.Text =raf.readObject(raf.CurrentPosition)
 

anaylor01

Well-Known Member
Licensed User
Longtime User
I tried the code below but am still getting file not found error.
B4X:
fdlg.Show("Load File","Load File","Cancel","",Null)
Dim fle As String
fle = fdlg.FilePath
lblfilename.text = fle & "/" & fdlg.ChosenName
Dim List1 As List
List1 = File.ReadList(File.DirDefaultExternal, lblfilename.text)
For i = 0 To List1.Size - 1
   ' Log(List1.Get(i))
    lblphonenumber.Text = list1.Get(i)
 
Upvote 0

anaylor01

Well-Known Member
Licensed User
Longtime User
It's a text file with only this value in it "111111111". I then pushed it onto the emulator's sd card.
 
Upvote 0

anaylor01

Well-Known Member
Licensed User
Longtime User
I figured out the folder thing now the code below returns "SQLite Format @)*$"
It should return just the one value that is in the text file "111111111"
B4X:
fdlg.Show("Load File","Load File","Cancel","",Null)
Dim fle As String
fle = fdlg.FilePath
lblfilename.text = fle & "/" & fdlg.ChosenName
'Msgbox(fle & " " & fdlg.ChosenName, "test")
Dim List1 As List
List1 = File.ReadList(File.DirrootExternal, fdlg.ChosenName)
lblphonenumber.text = File.ReadString(File.DirrootExternal, fdlg.ChosenName)
 
Upvote 0

anaylor01

Well-Known Member
Licensed User
Longtime User
Whoa. Thats weird. I right clicked on the desktop said new selected text file. Changed its name. Opened it up and put in 111111111. Copied it to ADB Folder. Pushed it to the SDcard. I just went back in to the ORIGINAL file I created on the desktop and it had the sqlite format and then a ton of garbled junk.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…