jeudi 2 juillet 2015

showing record in text view using sqlite table

i have created this method in dbHelper class. I am calling this method from mainActivity using onClickListener to show column 1 of each row one by one by changing cursor position. i need to move the cursor to next row each time the button is clicked to show the string in Column1 in a textView. i am new to android and programming too, so please bear with me.

public String nextData() { String nQuote = ""; int i=0; String[] columns = new String[] { KEY_ROWID, KEY_NAME, KEY_IQ }; Cursor resultSet = ourDatabase.query(DATABASE_TABLE, columns, null, null, null, null, null); resultSet.movetoPostion(i); if (i==0||i!=resultSet.getcount()){ resultSet.moveToNext(); nQuote = resultSet.getString(1); i++; } return nQuote; }

Aucun commentaire:

Enregistrer un commentaire