iOS Question Is there a tutorial on reading/writing .txt files

rfresh

Well-Known Member
Licensed User
Longtime User
I need to save some data in a file (.txt would be fine) and then have my app open the file and read in that data. Is there a tutorial on how to read and write .txt files?

Is this best done using a simple .txt file or is there another preferred way to save data?

Thank you...
 

rfresh

Well-Known Member
Licensed User
Longtime User
What library do I need? I selected the iRandomAccessFile but I still got the errors below.

These lines give an error: unknown member: File.DirRootExternal or ExternalWritable

B4X:
File.WriteString(File.DirRootExternal, "String.txt", _
If File.ExternalWritable = False Then

There is no File.WriteText in the example code in this URL: https://www.b4x.com/android/forum/threads/text-files.6690/

It seems to be for B4A and not B4i (at least there is no B4i tag in the URL page).
 
Upvote 0

rfresh

Well-Known Member
Licensed User
Longtime User
I created a file with the following code but I don't see it on my iPad:

B4X:
    If File.Exists(File.DirDocuments, "12.txt") = False Then
        File.WriteString(File.DirDocuments, "12.txt", "test")
    End If
 
Upvote 0

aaronk

Well-Known Member
Licensed User
Longtime User
Did you add the following code and watch the video from the link in my last post ?

B4X:
#PlistExtra: <key>UIFileSharingEnabled</key><true/>
 
Upvote 0

rfresh

Well-Known Member
Licensed User
Longtime User
Yes, I added that line of code.

And yes, I watched your video but didn't understand what it was doing. I am trying to write a file to my local iPad and not share it on iTunes.

In my iPad, my file manager shows me my Documents folder but I don't see the file in there.
 

Attachments

  • IMG_0088.PNG
    IMG_0088.PNG
    74.9 KB · Views: 223
Upvote 0

rfresh

Well-Known Member
Licensed User
Longtime User
>You need to do it with iTunes.

What does that mean Erel? That my file will be on iTunes and not on my iPad?
 
Upvote 0
Top