How to view the records in database via Click Event in Android?
I am using a cursor to view my records in a database. But an error is displayed.
ERROR/AndroidRuntime(3880): java.lang.IllegalStateException: get field slot from row 1 col -1 failed Run Time Excweption Sir – mnom 2 mins ago edit
Here is my code:
btn4.setOnClickListener(new View.OnClickListener(){开发者_StackOverflow中文版
public void onClick(View v){
dh.open();
Cursor c = dh.DisplayTitle();
String text = "";
c.moveToFirst();
while (c.moveToNext()) {
text = text+ "typ: " + c.getString(c.getColumnIndex(dh.DisplayTitle().toString()));
}
And my Datahelper
code:
public Cursor DisplayTitle()throws SQLException
{
Cursor c1=db.rawQuery("SELECT * from titles",new String []{});
if (c1 != null) {
c1.moveToFirst();
}
return c1;
}
精彩评论