The sort method Collections.sort(list)
works on the list even though I pass by reference. However, when I use the following method, the list does not get sorted.
public void getSortedList(ArrayList<String> currList) {
ArrayList<String> list = new ArrayList<>();
Cursor cursor = database.rawQuery(
"SELECT * FROM " + TABLE_NAME + " ORDER BY name DESC", null);
while (cursor.moveToNext()) {
String name = cursor.getString(0);
if (currList.contains(name)) {
list.add(name);
}
}
cursor.close();
currList = list;
}