Italian Accedere ad un file salvato in xui.DefaultFolder, fuori dall'app

Sabotto

Well-Known Member
Licensed User
Se salvo un file di log in xui.DefaultFolder, come posso accedervi poi esternamente.
Ho letto che con
File.Copy(xui.DefaultFolder, "NameFile", File.DirRootExternal, "NameFile"):
File.Copy(xui.DefaultFolder, "NameFile", File.DirRootExternal, "NameFile")
non funziona da Android 8 in poi.
Suggerimenti?
 

drgottjr

Expert
Licensed User
Longtime User
mai in File.DirRootExternal

con FileProvider, se vuoi salvarlo in Documents
salvare il file in GetSafeDirDefaultExternal("") se vuoi vederlo da un pc (fuori dall'app)
 

Sabotto

Well-Known Member
Licensed User
mai in File.DirRootExternal

con FileProvider, se vuoi salvarlo in Documents
salvare il file in GetSafeDirDefaultExternal("") se vuoi vederlo da un pc (fuori dall'app)
Copiarlo in Documents, andrebbe benissimo, ma non riesco a capire come fare con Fileprovider.
 

drgottjr

Expert
Licensed User
Longtime User
cerca in casella in sopra. o aspetta un po'; sto facendo colazione...
mi scusi; volevo dire ContentResolver, non FileProvider. l'esempio viene...
 
Last edited:

zed

Active Member
Licensed User
Non sono italiano, ma penso che sia così. 2 Esempi. 1: per utente, 2: automatico (per codice)
B4A:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Private xui As XUI
    Private rp As RuntimePermissions
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    Private FileHandler1 As FileHandler
    Private ImageView1 As ImageView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    
    Activity.LoadLayout("Layout")
    FileHandler1.Initialize
    
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Private Sub Button1_Click
    Dim in As InputStream = File.OpenInput(File.DirAssets, "word1.txt")
    Wait For (FileHandler1.SaveAs(in, "text/plain", "word1.txt")) Complete (Success As Boolean)
    If Success Then
        ToastMessageShow("File saved successfully", True)
    Else
        ToastMessageShow("File not saved", True)
    End If
End Sub

Private Sub Button2_Click
    Dim bmp As Bitmap
    bmp.Initialize(File.DirAssets, "as.png")
    Dim fileName As String = "as.png"
    Dim dir As String = rp.GetSafeDirDefaultExternal("myFolder")
    Dim Out As OutputStream = File.OpenOutput(dir, fileName, False)
    bmp.WriteToStream(Out, 100, "JPEG")
    Out.Close
    ImageView1.Bitmap = bmp
End Sub
 

Attachments

  • testcopy.zip
    177.1 KB · Views: 129

drgottjr

Expert
Licensed User
Longtime User
prendi
 

Attachments

  • sabotto.zip
    8 KB · Views: 125
Top