Android Question .txt open and save

Douglas Farias

Expert
Licensed User
Longtime User
hi to all

my question and objective is simples
i want to make a simple text save and open
button1 save
button2 open

questions

1- how i make to when a user click at button1 open a edittext to user put a name and save the file.txt
exemple: i m click at button1 open a textbox and i put name : teste , the app save a Textos/teste.txt ??

2- how can i click in button2 and select the file i want?
for exemple i m click at button 2 and show me all files in Textos folder and i select what i want, teste.txt for exemple ? *-*



this code is working to save and open but i cant save with the name i want
and i cant open a file i want in the texto folder *-*


Code:
Sub Button1_Click
If EditText1.Text.Length > 0 Then
File.WriteString(File.DirRootExternal, "Textos/1.txt", EditText1.Text)
'Msgbox=("Seu Texto foi salvo com sucesso na pasta Textos", "Like Apps")
Msgbox("Seu Texto foi salvo com sucesso na pasta Textos", "")
Else
' Msgbox=("Entre com o texto antes de salvar!","Like Apps")
Msgbox("Entre com o texto antes de salvar", "")
End If
End Sub
Sub Button2_Click
    EditText1.Text = File.ReadString(File.DirRootExternal, "Textos/1.txt")
End Sub

thx to all
remember i m not programmer only curious xD
 
i m not programmer , i m realy beginer xD can u post a simple exemple to save with name i want and open file i want?
 
Upvote 0
There is an example included in the Dialogs library post which you will need to download to get the library. Open the DialogsDemo.b4a and look at the btnFile_Click sub. If you get a problem, post a specific question.
 
Upvote 0
i m trying this but my question is now

how to put

/Textos folder when i click at button ?
i need search the Texto folder here and click i want to click and already open Textos folder *-*

Code:
fd.FilePath = File.DirRootExternal '
 
Last edited:
Upvote 0
Try:
Code:
Dim FP As String
If File.IsDirectory(File.DirRootExternal,"Textos") Then
    FP = File.Combine(File.DirRootExternal,"Textos")
Else
    FP = File.DirRootExternal
End if
fd.FilePath = FP
 
Upvote 0
Code:
Sub Button2_Click

Dim FP As String
If File.IsDirectory(File.DirRootExternal,"Textos") Then
    FP = File.Combine(File.DirRootExternal,"Textos")
Else
    FP = File.DirRootExternal
End If

    Dim fd As FileDialog
    fd.FastScroll = True
    fd.FilePath = FP  '  also sets ChosenName to an emtpy string
    fd.FileFilter = ".txt" ' for example or ".jpg,.png" for multiple file types
    ret = fd.Show("Abrir Texto", "Abrir", "", "", Null)   
    ToastMessageShow(ret & " : Path : " & fd.FilePath & CRLF & "File : " & fd.ChosenName, False)   
    EditText1.Text = File.ReadString(fd.FilePath,fd.ChosenName)
End Sub


this works fine thanks man
 
Upvote 0
and how to remove

mD5rnzXLI4RjXr7jFBDCM-rnNuvQz7WXYdj8t77X3eAzGEchW6DkvMrwY9L5aSDsRKQ=h900





AND HOW TO REMOVE

..
AND

↓FILES↓

?????
i need open only my .txt
dont .. button and ↓FILES↓ *-*
 
Upvote 0
Back
Top