I try to add an item to a list, but java get the unsupportedoperationexception error:
Sub insertlistDir(dir As String) As List
Dim lst As List
lst = File.ListFiles(dir)
lst.SortCaseInsensitive(True)
'If dir.indexOf2("/",1) > -1 Then lst.InsertAt(0,"..")
lst.add("..")
Return lst
End Sub
I've read that file.listfiles returns a read-only list. perhaps this is causing the error. could you try capitalizing a new list and copy the contents of the previous one? maybe it works.
Update: Try this:
B4X:
Dim lst As List
lst.Initialize
lst.AddAll (File.ListFiles(dir))
lst.SortCaseInsensitive(True)
'If dir.indexOf2("/",1) > -1 Then lst.InsertAt(0,"..")
lst.add("..")
Return lst
it is solved, the first error is the list must be initialised, the second is I can't manipulate a read only list wich seems is the case of File.ListFiles.