B4A Library [Class] File Explorer with visualization

Hi,

I created this class because I was frustrated by the File Dialog in the (great) Dialogs lib. With that class, you can customize everything (since you have the source code) and add new functions like rename, delete, create folder, etc.
Currently, the class can visualize picture and text files (or not if you set the option to false) when you select them.
You can make multiple selections.

If your activity contains a TabHost, loot at post #7.

Add this permission to the manifest for Android v4+:
AddPermission(android.permission.READ_EXTERNAL_STORAGE)


Since September 1st 2014, this class is completely free.

Enjoy,
Fred
 

Attachments

  • img1.jpg
    img1.jpg
    54.1 KB · Views: 3,550
  • img2.jpg
    img2.jpg
    68 KB · Views: 3,032
  • multi.png
    multi.png
    41.6 KB · Views: 2,835
  • FileExplorer v2.1.zip
    61.2 KB · Views: 2,350
Last edited:

padvou

Active Member
Licensed User
Longtime User
Hello,
If I use the longClick to delete a folder, how can the dlgFileExpl be refreshed in order to show that the folder has been removed?
EDit:

I have also added this code:
B4X:
Private Sub lstFichiers_LongClick(Item As Panel, ItemTag As Object)
    Dim lbl As Label
    If Item.GetView(0) Is CheckBox Then
        lbl = Item.GetView(1)
    Else
        lbl = Item.GetView(0)
    End If
    If csu.IsInitialized=False Then csu.Initialize
    csu.Call_SubPlus2(Main,"Delete_Pat",1000, Array("fname",lbl.Text))
    Return True
End Sub
in ClsExplorer.
The relevant Sub in main is this:
B4X:
Sub Delete_Pat(SelFolder2() As Object)
    Dim SelFolder As String=SelFolder2(1)
    'Dim result As Int    'Positive, cancel, negative
    Dim res = Msgbox2("Delete patent folder: " & CRLF & SelFolder.SubString(2),"Delete confirm", "Delete it", "", "Do not delete",Null)
    DoEvents
    If res=DialogResponse.POSITIVE Then
        ToastMessageShow(res, False)
        Try
            Dim fileList As List
            Dim N As Int
            fileList = File.ListFiles(File.DirRootExternal & "/DCIM/frameasure3/" & SelFolder.SubString(2) & "/")
            fileList.Sort(True)
            For N = 0 To fileList.Size-1
                File.Delete(File.DirRootExternal, "/DCIM/frameasure3/" & SelFolder.SubString(2) & "/" & fileList.Get(N))
                fileList.Get(N)
            Next
        Catch
            ToastMessageShow(LastException, False)
        End Try
        Try
            File.Delete(File.DirRootExternal & "/DCIM/frameasure3/",SelFolder.SubString(2) & "/")
        Catch
            ToastMessageShow(LastException, False)
        End Try
    else if res=DialogResponse.negative Then
        ToastMessageShow("Delete aborted", False)
   
    End If
   
   
    ToastMessageShow(res, False)
End Sub

However, the code shows the MsgBox, but continues running with a res value of -3, without waiting for the user to answer the MsgBox. So whatever is selected by the user has no effect.
 
Last edited:

padvou

Active Member
Licensed User
Longtime User
Could you please post a code snippet for the deletion of a long-clicked item in the list of the explorer with a msgbox to answer yes or no?
 

padvou

Active Member
Licensed User
Longtime User
Sorry but I have no time for this these days and I don't think that could work (no modal dialog in the explorer). Your best option is to display a panel above the explorer with two buttons Yes and No.
I would sincerely appreciate it if you could please at least tell me how to refresh the contents of the explorer, after a deletion is made?
 

JOTHA

Well-Known Member
Licensed User
Longtime User
Hello Informatix,
I created this class because I was frustrated by the File Dialog
I tried your Class, but there is always a ToastMessageShow "Unable to access folder" when I click on one of the buttons.

... DoEvents are deprecated, should I change them to "Sleep(0)" ?
 

Informatix

Expert
Licensed User
Longtime User
Hello Informatix,

I tried your Class, but there is always a ToastMessageShow "Unable to access folder" when I click on one of the buttons.
Read the first post of this thread. You forgot to add the permission.

... DoEvents are deprecated, should I change them to "Sleep(0)" ?
No. You can try but you will fail to make it work as expected.
 

JOTHA

Well-Known Member
Licensed User
Longtime User
Add this permission to the manifest for Android v4+:
AddPermission(android.permission.READ_EXTERNAL_STORAGE)
You wrote it and I didn't see it.
Thank you!
 

Alexander66

New Member
Hello. I got the file names;
MsgboxAsync(dlgFileExpl.Selection.ChosenFile) = (file1; file2; file3).
How to add and split file names in a ListView? Sorry for the auto-translation.
 
Top