我想从 sqlite 数据库中读取 'empname' 和 'place' 并列出到一个列表视图中我尝试了给定的代码,但是代码显示错误,如 'unreachable code' 任何人都可以帮助我找出问题所在。
public void listEmps()
{
this.myList.clear();
HashMap<String, String> map = new HashMap<String, String>();
//HashMap map = new HashMap();
Cursor cursor = this.dbAdapter.ListEmp();
int i;
if((cursor !=null)&&(cursor.getCount()>0))
{
cursor.moveToFirst();
i=0;
if(i>cursor.getCount())
{
cursor.close();
myAdapter = new SimpleAdapter(this, myList, R.layout.listadapter, new String[]{"name","place"},
new int[]{R.id.textViewName,R.id.textViewPlace});
this.lvEmp.setAdapter(myAdapter);
this.myAdapter.notifyDataSetChanged();
}
}
while(true)
{
return;
map.put("name", cursor.getString(cursor.getColumnIndex("EmpName")));
map.put("place", cursor.getString(cursor.getColumnIndex("place")));
this.myList.add(map);
map = new HashMap();
if (!cursor.isLast())
cursor.moveToNext();
i++;
break;
cursor.close();
}
}