Help with List.Add and List.RemoveAt

ChrShe

Member
Licensed User
Longtime User
Good day!

Please see the below cobbled together snippit:
B4X:
Dim favs As List
favs.Initialize
favs = File.ListFiles(Main.FavPath)
Dim Tst as string = "This is a test"
favs.Add(Tst)
For i = 0 to favs.Size
  If favs.Get(i) = Tst Then
    favs.RemoveAt(i)
  End If
Next
...

The problem I'm having is whenever I try to do a favs.Add() or favs.RemoveAt(), I get a java exception of "UnsupportedOperationException".

I've tried all the variations of these methods that I can come up with...
Any Ideas?

Oh...Main.FavPath is a valid path and does work. It equates to File.DirDefaultExternal & "/Favorites"

Also...Might there be a way to get File.ListFiles to get only a certain file type? *.txt for instance.
THANKS MUCH!!!!
 

ChrShe

Member
Licensed User
Longtime User
Oh! I'm mortified!

I've looked at that a number of times and never saw the "Read only" part.:sign0161:

Thank you!
:sign0013:
 
Upvote 0
Top