mardi 16 juin 2015

Return One value if more than one Exsist

if i have same values in a column and i want to return only one instead of all of them what would be a method.

ArrayList<String> getAllNotes() {
    Cursor cursor;
    mDbHelper = mSqliteHelper.getWritableDatabase();
    String query = "SELECT * FROM " + SqliteHelpers.TABLE_NAME;
    cursor = mDbHelper.rawQuery(query, null);
    ArrayList<String> arrayList = new ArrayList<>();
    while (cursor.moveToNext()) {
        String itemname = cursor.getString(cursor.getColumnIndex(SqliteHelpers.NOTES_COLUMN));
        if (itemname != null) {
            arrayList.add(itemname);
        }
    }
    return arrayList;
}

As you can see in image there are four items all are same but i want one tobe return other will be returned normal. except more than one.image

Aucun commentaire:

Enregistrer un commentaire