I have tried many different ways to do this, but basically when I get all of data from my database I want to store it in an array, but I do not know how to iterate through the index's as the data is read from the database. Here is how I am getting the data and adding it to the array:
public void makeObjects(){
i =0;
db.open();
for(int j = 0; j< amount; j++)
{
objarray.add(o);
}
Cursor c = db.fetchAllNotes();
if (c.moveToFirst())
{
do {
objarray.get(i).setid(c.getString(0));
objarray.get(i).settitle(c.getString(1));
objarray.get(i).setinfo(c.getString(2));
objarray.get(i).setlat(c.getString(3));
objarray.get(i).setlon(c.getString(4));
objarray.get(i).setmc(c.getString(5));
i++;
} while (c.moveToNext());
}
db.close();
}
For testing and simplicity I have two rows in my database, I have a for loop which adds two new indexes to the array, but when I print out the contents of the array to the logcat, I see that both indexes have the last data to be read from the database, the second row twice. How can I make sure that row one enters index 0 and row two enters index 1?