2 回答
TA贡献1815条经验 获得超10个赞
设置你的Adapter外部while loop
//get the data to the list view
if(result.getCount() == 0 ){
Toast.makeText(StockSearchActivity.this,"Databse is empty",Toast.LENGTH_LONG).show();
}else{
while (result.moveToNext()){
theList.add(result.getString(0));
theList.add(result.getString(1));
theList.add(result.getString(2));
theList.add(result.getString(3));
theList.add(result.getString(4));
}
ListAdapter listAdapter = new ArrayAdapter<>(this,android.R.layout.simple_expandable_list_item_1,theList);
listView.setAdapter(listAdapter);
}
TA贡献1876条经验 获得超5个赞
你的问题在下一行
SQLiteDatabase db = this.getWritableDatabase();
当您尝试从数据库中获取数据时,它应该以可读模式打开,如下所示。
SQLiteDatabase db = this.getReadableDatabase();
添加回答
举报