I am trying to get column data from sqlLite DB and put that data into an array method and then call the method and display the data, for some reason I am only getting the first variable in my column, help please!!!!
-Yes there are more variables in that column
public String[] getScore01() {
String[] column1 = new String[] { KEY_NAME };
Cursor c = ourDatabase.query(DATABASE_TABLE, column1, null, null, null,
null, null);
String[] result = {};
int iName = c.getColumnIndex(KEY_NAME);
for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()) {
String[] result1 = { "" + c.getString(iName) };
result = result1.clone();
}
return result;
}
and here we call the method and get the data set it to an array…
Database info = new Database(this);
info.open();
String[] data = info.getScore01().clone();
info.close();
setting the textview tvVVTEST to data[0] works, but setting it to data[1] or anything else fails why???
tvVVTEST.setText("" + data[0]); //works
//tvVVTEST.setText("" + data[1]); // Does Not Work
No need to call like this. Change this to
And you have declared result two times.Second make sure that array value will insert on new position everytime.Otherwise it will over write and you will get only one value
Edited
changes inside loop to