#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim xui As XUI
Dim mySavePath As String
Dim myFileName As String
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
Dim B As Button
B.Initialize("BTN")
B.text="RENAME"
Activity.AddView(B,50dip,50dip,100dip,100dip)
Dim RP As RuntimePermissions
mySavePath=RP.GetSafeDirDefaultExternal("")
myFileName="Test.txt"
File.WriteString(mySavePath,myFileName,"Something to write...")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub BTN_Click
Dim D As B4XDialog
D.Initialize(Activity)
Dim opt As B4XInputTemplate
opt.Initialize
opt.lblTitle.text="Choose an action"
opt.Text=myFileName
Dim oldName As String=myFileName
Wait For (D.ShowTemplate(opt, "Rename", "Duplicate", "Cancel")) Complete (Result As Int)
If Result = xui.DialogResponse_Cancel Then Return
Dim newName As String=opt.TextField1.Text
Log(newName)
If newName=oldName Then Return
File.Copy(mySavePath,oldName,mySavePath,newName)
If Result=xui.DialogResponse_Positive Then
File.Delete(mySavePath,oldName)
End If
End Sub