0
I’m trying to insert the contents of a table into sqlite
within a listview
. The table in Sqlite is already filled, the listview was being filled with result of webservice
, which also works ok, but I’m saving the values in an Sqlite so that the query is faster the next time the user accesses. The following error appears in logcat when trying to insert in listview:
java.lang.Illegalstateexception: Couldn’t read Row 0, col -1 from Cursorwindow. Make sure the Cursor is initialized correctly before accessing data from it.
Follow the code below the error happens enters the line categoria_produtoList.add(0, member);
public List<Ac_Df_Produto_Categoria> getAll() {
List<Ac_Df_Produto_Categoria> foos = new ArrayList< Ac_Df_Produto_Categoria>();
Ac_Df_Produto_Categoria member = null;
SQLiteDatabase db = this.getWritableDatabase();
Cursor c = null;
try {
c = db.rawQuery("Select * FROM " + NOME_TABELA_TERMOS_USO, null);
if (c.moveToFirst()) {
do {
member = new Ac_Df_Produto_Categoria();
member.setId(c.getInt(c.getColumnIndex("id")));
member.setPCT_ID(c.getInt(c.getColumnIndex("PCT_ID")));
member.setDescricaoInternet(c.getString(c.getColumnIndex("DescricaoInternet")));
member.setPossui_tamanho(c.getString(c.getColumnIndex("Possui_tamanho")));
foos.add(member);
Log.d("Categoria",c.getString(c.getColumnIndex("DescricaoInternet")));
categoria_produtoList.add(0, member);
adapter.notifyDataSetChanged();
swipeRefreshLayout.setRefreshing(true);
} while (c.moveToNext());
}
return foos;
}
finally {
if (c != null) {
c.close();
}
}
}
What is this
categoria_produtoList
? Is your listview?– user28595
Actually it is the class that represents the table in the BD-DAO private List<Ac_df_product_category> categorie_productList;
– gleyson faustino da silva