Just starting out? Need help? Post your questions and find answers here.
tj1010
 
Posts: 182
Joined: Wed May 27, 2015 1:36 pm

IOS and Android local files

by tj1010 Tue Oct 24, 2017 5:37 pm

Does the local storage flag in 2.20 CreateFile() make sandboxed/local files on Android and IOS? I'm curious cause there is no domain with .app and .apk runtimes.

I'm on the move and will be for a while so won't be able to find out myself for a while. This code should reveal the answer though..

Code: Select all
Procedure Callback(Status, Filename$, File, SizeRead)
  Select Status
    Case #PB_Status_Saved
      ; File correctly saved
      Debug "file saved"
    Case #PB_Status_Error
      ; File saving has failed
      Debug "file save error"
    Case #PB_Status_Loaded
      ;read out the file in to the debug window
      Debug "file loaded now reading lines..."
      While Eof(0)=0
        Debug ReadString(0)
      Wend
  EndSelect
EndProcedure

If Not OpenFile(0,"Text.txt",@Callback(),#PB_LocalStorage)
  If CreateFile(0, "Text.txt", @Callback(),#PB_LocalStorage)      ; we create a new text file
    For a=1 To 10
      WriteStringN(0, "Line "+Str(a))  ; we write 10 lines (each with 'end of line' character)
    Next
    For a=1 To 10
      WriteString(0, "String"+Str(a))  ; and now we add 10 more strings on the same line (because there is no 'end of line' character)
    Next
    CloseFile(0)                     
  EndIf
Else
  CloseFile(0)
EndIf
Return to Coding Questions

Who is online

Users browsing this forum: No registered users and 2 guests