• Dear Cerberus X User!

    As we prepare to transition the forum ownership from Mike to Phil (TripleHead GmbH), we need your explicit consent to transfer your user data in accordance with our amended Terms and Rules in order to be compliant with data protection laws.

    Important: If you accept the amended Terms and Rules, you agree to the transfer of your user data to the future forum owner!

    Please read the new Terms and Rules below, check the box to agree, and click "Accept" to continue enjoying your Cerberus X Forum experience. The deadline for consent is April 5, 2024.

    Do not accept the amended Terms and Rules if you do not wish your personal data to be transferred to the future forum owner!

    Accepting ensures:

    - Continued access to your account with a short break for the actual transfer.

    - Retention of your data under the same terms.

    Without consent:

    - You don't have further access to your forum user account.

    - Your account and personal data will be deleted after April 5, 2024.

    - Public posts remain, but usernames indicating real identity will be anonymized. If you disagree with a fictitious name you have the option to contact us so we can find a name that is acceptable to you.

    We hope to keep you in our community and see you on the forum soon!

    All the best

    Your Cerberus X Team

external file path?

phj

New member
Joined
Feb 2, 2020
Messages
8
a.png


I want read file in red circle.

I tried "cerberus://external/a.txt"

but wrong.

Where is the right path?
 
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.
 
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.
Thank you MikeHart.

I'm Understand.

I have old project using "Monkey-x"

code are
------------------------------
Field DATAPATH:String = "Z:/Project/tile/"

Method OnCreate:Int()
#If TARGET="android"
DATAPATH = "monkey://external/tile/"
#Endif
------------------------------------------------------------
It is possible.

However not possible in "Cerberus-x"

I have to use a file in two apps at the same time.
 
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.
 
Btw. Your code example is different from a text file inside the root folder of your Android phone.
 
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.

I searched for advice.

ooooooops!!
solved!!
Turn on storage for app permissions.

path are

#If TARGET="android"
DATAPATH = "/mnt/sdcard/Download/"
#Endif
Local file:= FileStream.Open(DATAPATH + "b.txt", "r")

succesded!!

Thank you for helping!!!!!!!

I'm making a tile editor ^^
Screenshot_20200217-132424[1].jpg
 
Last edited:
Turn on storage for app permissions.
How did you turn permission on? I would like to store things on my Android phone's sd card like a Nintendo cartridge.
 
The permissions seem to be already in there? Where do you need to enable it?
Maybe I need to find the SD card path on my device, I know they might be different on different brands and models.

Screenshot 2020-07-03 at 08.02.48.png
 
Look into resource paths in the docs. Use external for the SD card.
 
Do anyone know why this code acts like it does?

After trying a lot of different paths finally I found something that works on my Android phone. I'm so happy about that!
But, why does it access the internal memory instead of the sd card?
Cerberus:
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
 
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).

1.jpg
 

Attachments

  • 2.jpg
    2.jpg
    1.4 MB · Views: 157
  • 3.jpg
    3.jpg
    2.9 MB · Views: 150
  • 4.jpg
    4.jpg
    1.8 MB · Views: 146
After hours gf Googling and testing I found out that on my Android 7 phone
these are the only paths that works :

Is there a command that lists available paths on any device and spits out the strings that works?

/mnt/sdcard//
/storage/emulated/0//

Sadly they are the same (internal memory)
I've found no working path for the external SD card.

Cerberus:
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
 
Since Android 10, Google disabled the access to the SD card with the regular API. From what I saw today, you would have to do some magic tricks to do it.
 
If Google closed up the SD card access for "programmatic saving" I'm thinking; maybe they want everyone to use manual
saving techniques to reach SD card, things like share / intents (and hava a file option in there).

So what about creating an Android sharing/intent function that allows the user to choose the storage card manually?
Would it be hard to make?
 
Back
Top Bottom