I have an ArrayList
variable named counties
and I am extracting data from my database and adding it to this ArrayList
with the following code:
//Get all data from database
Cursor cursor = database.rawQuery("SELECT * FROM " + tableName, null);
//Add Counties to ArrayList
cursor.moveToFirst();
while(!cursor.isAfterLast()){
counties.add(cursor.getString(cursor.getColumnIndex("COUNTY")));
cursor.moveToNext();
}
I am then displaying this data in a ListView
which will allow the user to select a County and be taken to another activity.
The data is such that there are multiple records with the same county, thus it looks like:
COUNTIES
______________
West Yorkshire
West Yorkshire
Lancashire
Warwickshire
Cornwall
Lancashire
West Yorkshire
I want only one instance of each county to be shown and have struggled thus far to find a solution.