Try like
String data1 = ((Cursor) sp1.getSelectedItem()).getString(0);
mySQLiteAdapter.insertGrade(data1);
문제
My problem is the sp1.getSelectedItem().toString();
only saves the data as android.database.SQLite.cursor@blablabla
... it's not getting the string as I declared... How can I do this?
here's my code for cursor[populating the spinner]
cursor = mySQLiteAdapter.queueSchoolAll();
cursor.requery();
String[] from1 = new String[]{Database.KSCHOOLCODE};
int[] to1 = new int[]{R.id.rt1};
cursorAdapter =
new SimpleCursorAdapter(this, R.layout.a_row_school, cursor, from1, to1);
sp1.setAdapter(cursorAdapter);
here's the code of the button that will save the data:
String data1 = (String)sp1.getSelectedItem().toString();
mySQLiteAdapter.insertGrade(data1);
해결책
Try like
String data1 = ((Cursor) sp1.getSelectedItem()).getString(0);
mySQLiteAdapter.insertGrade(data1);
다른 팁
You need to get data from cursor. For example:
public xxxxxx onItemClickFunction(..., int position,....){
int pos = cursor.getPosition();//saving the position just in case
cursor.moveToPostion(position);// moving to the position where a click is fired
String val = cursor.getString(column index);
cursor.moveToPosition(pos);// moving back to original position.
}