I saved some file in my app now I want to show the ones which are ended by .txt on my listview
not all of them. Could you please help me?
Here is how I generated my listview:
void ShowSavedFiles(){
SavedFiles = fileList();
ArrayAdapter adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1,
SavedFiles);
listSavedFiles.setAdapter(adapter);
}
Here is the solution:
void ShowSavedFiles(){ArrayList<String> filteredList = new ArrayList<String>();
SavedFiles = fileList();
for(String str: SavedFiles) {
if (str.trim().contains("_cred.txt")) {
filteredList.add(str.trim());}
}
ArrayAdapter adapter
= new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1,
filteredList);
listSavedFiles.setAdapter(adapter);}