java - Get data from sqlite on android -


i trying fetch data sqlite database on android. however, when run code , see android monitor, message:

04-14 15:27:27.737 11177-11177/com.example.daniel.toto e/cursorwindow: failed read row 0, column -1 cursorwindow has 6 rows, 5 columns.

this method in database helper class use data database:

public arraylist<string> getallsales() {     arraylist<string> array_list = new arraylist<string>();      sqlitedatabase db = this.getreadabledatabase();     cursor res;     res = db.rawquery( "select * sales", null );     if (res != null) {         res.movetofirst();          while (res.isafterlast() == false) {             array_list.add(res.getstring(res.getcolumnindex(sales_table_name)));             res.movetonext();         }         return array_list;     } else {         array_list = null;     }     return array_list; } 

this call in oncreate method activity:

protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_sales);     mydb = new salesdbhelper(this.getbasecontext());     array_list = mydb.getallsales(); } 

thank deciphering error message. indeed part of error message column -1means: there no such column. thank lot pointing out, solved problem!


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -