Thank you MikeHart! If so "cerberus://internal/a.txt" <- that correct? else access sd card?You can't. External refers to androids external storage
Thank you MikeHart.Can of worms....
Internal refers to the sandboxed internal storage of that specific app.
External is an area for your app that is accessable by other apps.
Please read into this on the Android developer docs.
With both filepaths you can not browse in CX through all directories on your phone like you want to.
Why do you want to open this file? Maybe there is a different way to achieve what you are after.
I would be surprised if it is not working anymore. The only thing that has changed regarding file pathsin CX is thst you have to replace monkey with cerberus. You can do yourself a file compare. These are the only changes i think.
How did you turn permission on? I would like to store things on my Android phone's sd card like a Nintendo cartridge.Turn on storage for app permissions.
Strict
Import mojo
Import brl
Function Main:Int()
New myClass
Return 0
End
Class myClass Extends App
Field so:String[]
' -----------------------------------------------------------------
Method OnCreate:Int()
SetUpdateRate 60
Local s:String
s = "brian~nJohn3~nPeter"
' Local fw:= FileStream.Open("test1.txt","w")
' Local fw:= FileStream.Open("cerberus://data/test2.txt","w")
' Local fw:= FileStream.Open("cerberus://internal/test3.txt","w")
' Local fw:= FileStream.Open("cerberus://external/test4.txt","w")
Local fw := FileStream.Open("/mnt/sdcard//" + "b.txt", "w")
If fw <> Null
Print "File open to write"
fw.WriteString(s)
fw.Close()
Else
Print "File not open to write"
Endif
' Local fr := FileStream.Open("test1.txt","r")
' Local fr := FileStream.Open("cerberus://data/test2.txt","r")
' Local fr := FileStream.Open("cerberus://internal/test3.txt","r")
' Local fr := FileStream.Open("cerberus://external/test4.txt","r")
Local fr := FileStream.Open("/mnt/sdcard//" + "b.txt", "r") ' internal phone (set storageenable on app)
If fr <> Null
Print "File open to read"
Local s2:String = fr.ReadString()
fr.Close()
Print ("------------------")
Print ("s2="+s2)
Print ("------------------")
so = s2.Split("~n")
Print ("Count="+so.Length())
Else
Print "File not open to read"
Endif
Return 0
End
' -----------------------------------------------------------------
Method OnUpdate:Int()
Return 0
End
' -----------------------------------------------------------------
Method OnRender:Int()
Cls 0,0,128
SetColor 128,128,128
PushMatrix
Translate DeviceWidth()/2,DeviceHeight()/2
Scale 2.0,2.0
For Local y:Int = 1 To so.Length()
DrawText so[y-1], 0, 0+y*20, .5, .5
Next
PopMatrix
Return 0
End
' -----------------------------------------------------------------
End
Strict
Import mojo
Import brl
Function Main:Int()
New myClass
Return 0
End
Class myClass Extends App
Field so:String[]
' -----------------------------------------------------------------
Method OnCreate:Int()
SetUpdateRate 60
Local s:String
s = "brian~nJohn3~nPeter"
' Local fw:= FileStream.Open("test1.txt","w")
' Local fw:= FileStream.Open("cerberus://data/test2.txt","w")
' Local fw:= FileStream.Open("cerberus://internal/test3.txt","w")
' Local fw:= FileStream.Open("cerberus://external/test4.txt","w")
' Local fw := FileStream.Open("/mnt/sdcard//" + "b.txt", "w")
Local fw := FileStream.Open("/storage/emulated/0//" + "b.txt", "w") 'or / at end (not wo / i think)
If fw <> Null
Print "File open to write"
fw.WriteString(s)
fw.Close()
Else
Print "File not open to write"
Endif
' Local fr := FileStream.Open("test1.txt","r")
' Local fr := FileStream.Open("cerberus://data/test2.txt","r")
' Local fr := FileStream.Open("cerberus://internal/test3.txt","r")
' Local fr := FileStream.Open("cerberus://external/test4.txt","r")
' Local fr := FileStream.Open("/mnt/sdcard//" + "b.txt", "r") ' internal phone (set storageenable on app)
Local fr := FileStream.Open("/mnt/sdcard//" + "b.txt", "r") ' internal phone (set storageenable on app)
If fr <> Null
Print "File open to read"
Local s2:String = fr.ReadString()
fr.Close()
Print ("------------------")
Print ("s2="+s2)
Print ("------------------")
so = s2.Split("~n")
Print ("Count="+so.Length())
Else
Print "File not open to read"
Endif
Return 0
End
' -----------------------------------------------------------------
Method OnUpdate:Int()
Return 0
End
' -----------------------------------------------------------------
Method OnRender:Int()
Cls 0,0,128
SetColor 128,128,128
PushMatrix
Translate DeviceWidth()/2,DeviceHeight()/2
Scale 2.0,2.0
For Local y:Int = 1 To so.Length()
DrawText so[y-1], 0, 0+y*20, .5, .5
Next
PopMatrix
Return 0
End
' -----------------------------------------------------------------
End
I solved it this way too.I forgot to say that have to do this before file access works at all. I was struggling with this for quite some time before I found this out (follow each step image 1 - 4).
View attachment 944