Android Question multiple files copy to a user selected folder help

giggetto71

Active Member
Licensed User
Longtime User
Hi,
I am trying to copy some files from my app file.DirInternal to a user selected target folder (say Documents or Download or anything they can browse). apparently from some android versions on the DirInternal cannot be accessed by user if the app is installed under android/data.
I went trough Erel's below example but in this example the user selects a file while I would like the user to select the folder and then cycle the files I need to copy from the DirInternal to the selected folder.


thanks for your help.
 

sanjog shakya

Member
Licensed User
Longtime User
I used it to share or save to user specified folders or other. Please try this...
Save File to User Specified Directory:
Private Sub btnShare_Click
    Dim provider As FileProvider
    provider.Initialize
    Dim filename As String = "tempImage.jpg"
    Dim f As String = provider.SharedFolder

    Dim bmp As B4XBitmap = ZoomImageView1.ImageView.GetBitmap
    Dim out As OutputStream = File.OpenOutput(f,filename,False)
    bmp.WriteToStream(out,100,"JPEG")
        
    Dim i As Intent
    i.Initialize(i.ACTION_SEND,"")
    i.PutExtra("android.intent.extra.STREAM", provider.GetFileUri(filename))
    i.SetType("image/*")
    i.Flags = 1
    StartActivity(i)

End Sub
 
Upvote 0

giggetto71

Active Member
Licensed User
Longtime User
thanks, actually I am looking for a way to select the folder. just the folder. I will copy the files programmatically.
I could not run your example (not sure what is zoomimageview1, but I am not sure it only select and return the folder. maybe I am wrong
 
Upvote 0

sanjog shakya

Member
Licensed User
Longtime User
thanks, actually I am looking for a way to select the folder. just the folder. I will copy the files programmatically.
I could not run your example (not sure what is zoomimageview1, but I am not sure it only select and return the folder. maybe I am wrong
Please view this thread https://www.b4x.com/android/forum/threads/externalstorage-access-sd-cards-and-usb-sticks.90238/
Unzip the library file 'ExternalStorage.bas' and check selectDir method that may work for you.
 
Upvote 0

giggetto71

Active Member
Licensed User
Longtime User
thank you very much, at the end I gave up and went back to the idea of saving one file at the time with the user selecting the path for the file, using the save as example in the first post.
thanks for your help anyway
 
Upvote 0
Top