In my application I am receiving the DISTINCT value from rows that are in a column. I am looking to count how many items have this same value. An example would be
if I have an array {1,1,2,2,1,2,2,3}
I am seeking to derive the value of int 3 for distinct value 1 as it appears 3 times in the array.
The setting is I am using SQLiteDatabase in my Android Application.
I'm seeking to derive the information in my adapter so that I can present the count
my database helper makes this call called getGroupsList
public ArrayList<String> getGroupsList(){
ArrayList<String> allGroups = new ArrayList<>();
String groupsList = "select DISTINCT " + Flower.COLUMN_GROUPS + " from " + Flower.TABLE_NAME;
Cursor cursor = getReadableDatabase().rawQuery(groupsList, null);
if (cursor.getCount() > 0){
cursor.moveToFirst();
while(!cursor.isAfterLast()){
allGroups.add(cursor.getString(0));
cursor.moveToNext();
}
}
cursor.close();
return allGroups;
}
This retrieves the object that contains each Distinct value from the particular column if that helps to understand context. Your assistance is appreciated.