iOS Question Create "public" folder in iOS

Motorrad

Member
Licensed User
Longtime User
Hi Erel,
How can I create with B4i a "public" directory / folder?
I would like to access it with my developed app and in this folder I would like to edit normal with the "normal" file-explorer.
It is in B4A "File.DirRootExternal" ... and in B4i ??
I do not want to access the folder via iTunes (with file.dirdocuments).
I have read the post: iOS Tutorial Files and Folders
This does not come to the solution ...
Can you help me ?
Best regards from Germany
 

Motorrad

Member
Licensed User
Longtime User
Many thanks for your response. But I do not understand...
Maybe I explain my problem wrong. My English is not good.
Bought apps have their own folder. I can copy something in these. These apps can access these files. I also want to do this with my app ( with my own folder) !
That must be possible?
 
Upvote 0

Motorrad

Member
Licensed User
Longtime User
No. Not so complicated. I just want to create a folder and access it with my app and with a file explorer.
 
Upvote 0

mcqueccu

Well-Known Member
Licensed User
Longtime User
I think this is what you want. Use File.DirDocuments
and then add this
B4X:
#PlistExtra: <key>UIFileSharingEnabled</key><true/>

 
Upvote 0

Motorrad

Member
Licensed User
Longtime User
Hhhmm ... I wish that I can open this folder (my folder) with the FileExplorer ...
And not only with iTunes ...
 
Last edited:
Upvote 0

Motorrad

Member
Licensed User
Longtime User
Many thanks for the answer.
Now I've tried on my iPAD following code:


B4X:
'Code module
#Region  Project Attributes
    #ApplicationLabel: B4i Example
    #Version: 1.0.0
    'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
    #iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
    #iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
    #Target: iPhone, iPad
    #ATSEnabled: True
    #MinVersion: 8
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
    Public App As Application
    Public NavControl As NavigationController
    Private Page1 As Page
    Private xui As XUI
End Sub

Private Sub Application_Start (Nav As NavigationController)
    NavControl = Nav
    Page1.Initialize("Page1")
    Page1.RootPanel.LoadLayout("Page1")
    NavControl.ShowPage(Page1)
End Sub

Sub Button1_Click
    xui.MsgboxAsync("Hello world!", "B4X")
End Sub

Private Sub Page1_Resize(Width As Int, Height As Int)
    
End Sub


Sub Page1_Click
    Dim avc As ActivityViewController
    avc.Initialize("avc", Array(CreateFileUrl(File.DirLibrary, "1.pdf")))
    avc.Show(Page1, Page1.RootPanel)
End Sub

'Doesn't work with assets files. You must first copy them.
Sub CreateFileUrl (Dir As String, FileName As String) As Object
    Dim no As NativeObject
    no = no.Initialize("NSURL").RunMethod("fileURLWithPath:", Array(File.Combine(Dir, FileName)))
    Return no
End Sub

Sub avc_Complete (Success As Boolean, ActivityType As String)
    Log($"Success: ${Success}, ActivityType: ${ActivityType}"$)
End Sub

'Sub Page1_Click
'   Dim avc As ActivityViewController
'   avc.Initialize("avc", Array("Some text to share together with an image", LoadBitmap(File.DirAssets, "smiley.png")))
'   avc.Show(Page1, Page1.RootPanel) 'Second parameter is relevant for iPad only. The arrow will point to the view.
'End Sub
'
'Sub avc_Complete (Success As Boolean, ActivityType As String)
'   Log($"Success: ${Success}, ActivityType: ${ActivityType}"$)
'End Sub

But both code sections do not work on my iPAD! What am I doing wrong?
The result:


Does anyone have a complete example?
 
Upvote 0

Motorrad

Member
Licensed User
Longtime User
I had forgotten to copy the file to the folder "Dirlibrary" ... Now it's working ! Thank you again
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…