This maybe looks stupid and/or easy question but I couldn't done this.
I'm getting data from database (only). I need get both element and its id at the same time. For example,
+----------------+
| id | username |
+----------------+
| 1 | user1 |
| 12 | user2 |
| 103 | user3 |
+----------------+
When I populate the ArrayList or ArrayAdapter (or maybe something else), I want to get the both id and username.
I tried to use add(int index, String object) method in ArrayList and insert(String object, int index) method in ArrayAdapter. But the both methods return me same error:
java.lang.IndexOutOfBoundsException: Invalid index 12, size is 1
How can I solve this problem?
Thanks.