I'm implementing a sortable listview using bauerca's library here. This works, but now I need to define some things where I need some help. This is the functionality of my app_
I can create up to 5 names. These names are saved in a SQLite database. Then, in other activity, these names are loaded from the database and shown to select which ones I'm going to use.
With 5 names, there are several combinations I can use, but the basic porpouse of this app is that when I select some names, these are shown in a sortable listview where I can sort them. After sorting them, they should be saved in another database to remember the position of each one.
For this, the second database has these columns: NAME, GROUP, ORDER.
My approach is this: if I select for example NAME1
and NAME2
, this would be GROUP2_1
. If I select NAME1
and NAME3
this would be GROUP2_2
... and this with all the posible combinations. Then, in the ORDER
column, the position of each name in the listview is saved.
But seems that this approach with the GROUP column doesn't work... it saves the position of each name, but regardless of the group to which it belongs. So for example, if I have these names:
MARK
PAUL
JERRY
If I select MARK and JERRY, the listview at first time would show them that way:
MARK
JERRY
But now I sort them:
JERRY
MARK
So these combination belongs to GROUP2_1 and JERRY has 1 value in the ORDER column and MARK the 2.
If now I go back and I select this other combination:
MARK
PAUL
JERRY
This should be GROUP3_1, and now I sort them this way:
MARK
JERRY
PAUL
So now MARK has ORDER value 1, JERRY 2 and PAUL 3.
Now if I go back and load again the first combination, it will load the names with the last asigned ORDER value so instead of loading in this order:
JERRY
MARK
It will load them using the values of the last combinations:
MARK
JERRY
Sorry for such a long explanation, but I dind't know other best way to explain my issue. In resume, the problem is that the ORDER value is asigned to each name, regardless of the GROUP, so this is not a valid approach for what I need to get.
Update -- key definition
Thats my current table:
db.execSQL("CREATE TABLE " + TABLE_NAME + " (" +
TravelOrder._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
TravelOrder.NAME + " TEXT NOT NULL " +
");");