B4J Question [SOLVED] xui.default folder needs array ?

Peter Lewis

Well-Known Member
Licensed User
Longtime User
Hi,

I am trying to specify default folder. Every option I tried tells me that it requires an array.

Please can you show me the correct format.

Thank you


B4X:
    Dim appname As String ="ledposter-player"
    
    xui.SetDataFolder(appname)
    xui.DefaultFolder(appname)
    
    'tried
    
    'xui.DefaultFolder("C:\Users\peter\AppData\Roaming\ledposter-player")
    'xui.DefaultFolder(array as string("C:\Users\peter\AppData\Roaming\ledposter-player"))
    'xui.DefaultFolder(array("C:\Users\peter\AppData\Roaming\ledposter-player"))
    
'    then
    
'    dim appname() as string
'    appname(0) = "ledposter-player"
    
'    xui.DefaultFolder(appname(0))
    
'    xui.DefaultFolder(File.DirData("ledposter-player"))
'    xui.DefaultFolder((Array As String ("ledposter-player"))
'    xui.DefaultFolder(File.DirData(Array As String ="ledposter-player"))
 

Peter Lewis

Well-Known Member
Licensed User
Longtime User
Thank you, I misunderstood it. I already had
B4X:
    Dim appname As String ="ledposter-player"
    
    xui.SetDataFolder(appname)

Then I was trying to specify the default folder - my BAD.

So I can use the default folder to get the path for the Raspberry Pi folder

Thank you
 
Upvote 0

Peter Lewis

Well-Known Member
Licensed User
Longtime User
xui.SetDataFolder(appname) --> write or assign a subfolder
xui.DefaultFolder --> read or get the folder path
Ok, so I ran a very simple app through the B4J bridge. Put in this code
B4X:
#Region Project Attributes
    #MainFormWidth: 600
    #MainFormHeight: 600
#End Region

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private xui As XUI
    Private Button1 As B4XView
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show
    xui.SetDataFolder("ttrp")
End Sub

Sub Button1_Click

  
    xui.MsgboxAsync(xui.DefaultFolder, "B4X")
    Log(xui.DefaultFolder)
End Sub

and I got this folder on the Pi5. Is it a temp folder because I am using the remote bridge ?
or will all apps run on the Pi5 use the same folder ?

Thank you


/home/djpeterlewis/Downloads/tempjars
if I disconnected the bridge, it correctly displays the Windows folder
C:\Users\peter\AppData\Roaming\ttrp
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Is it a temp folder because I am using the remote bridge ?
yes

In rpi (Linux) production, you have to put your app at the path where the user has permissions.
Maybe /home/pi/MyApp, /opt/MyApp or /etc/MyApp

However, I prefer to put any documents, sqlite or app generated files in the same path of the jar using
B4X:
File.DirApp

Once you have build a standalone package, you can put your app to any path you like as long as permission is granted.
You can also let the app reads the path from a config file.
 
Upvote 0

Peter Lewis

Well-Known Member
Licensed User
Longtime User
ok, thank you
 
Upvote 0

Peter Lewis

Well-Known Member
Licensed User
Longtime User
lets just say I am confused again.

I took the .jar file and ran it on the Pi to see what path it gave me after specifying the app name , I expected a path with the app name inside but it showed me the path or where I have the .jar file


I then presume on the Pi OS it does not matter what I specify as the XUI.SetDataFolder is, It will always use the folder where the .jar is ? and windows will put it under APPDATA/ .... and the Appname
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
I think so.
From the Tooltips, it is mentioned that it only applies to Windows and Mac.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…