I' ve a troble with moving data from Cursor
to PageFragment
.
I read all data from Cursor
, but in PageFragment
goes only last value.
So positions go ahead(0,1,2,..), but from cursor it goes only last one.
How can I solve this problem?
HELP, please!
public android.support.v4.app.Fragment getItem(int position) {
while (cursor.moveToNext()){
GlobalVars.ditty = cursor.getString(cursor.getColumnIndex(DB.COLUMN_DIT));
}
return PageFragment.newInstance(position, GlobalVars.ditty);
}
public static class GlobalVars {
public static String ditty;
}
I read all data from Cursor, but in PageFragment goes only last value
Because inside while loop you are assigning new value to GlobalVars.ditty
in each iteration so either append new value to GlobalVars.ditty
with separator or use any data structure to store values like ArrayList,HashMap,... :
while (cursor.moveToNext()){
GlobalVars.ditty +=
cursor.getString(cursor.getColumnIndex(DB.COLUMN_DIT));
}