Android 数据库与MapView总结
2010-11-05 00:54:34 来源:WEB开发网Button mButton01 = (Button)d.findViewById(R.id.myButton2);
mButton01.setOnClickListener(new Button.OnClickListener()
{
public void onClick(View arg0)
{
// TODO Auto-generated method stub
String[] updateFields =
{
"f_name", "f_address", "f_cal"
};
String[] updateValues =
{
mEditText01.getText().toString(),
mEditText02.getText().toString(),
mEditText03.getText().toString()
};
String where = "f_id=?";
String[] whereValue =
{
allRestaurantID.get(intItemSelected)
};
/* 调用update()更新数据表里的记录 */
int intCol = dbHelper.update
(
tables[0], updateFields, updateValues,
where, whereValue
);
/* 返回更新成功笔数 >0时 */
if(intCol>0)
{
updateListView();
}
d.dismiss();
}
});
d.show();
}
break;
case 1:
/* 删除数据 */
if(intItemSelected>=0)
{
String where = "f_id=?";
String[] whereValue =
{
allRestaurantID.get(intItemSelected)
};
int intCol = dbHelper.delete
(
tables[0], where, whereValue
);
/* 返回删除成功笔数 >0时 */
if(intCol>0)
{
/* 删除成功 */
updateListView();
}
}
break;
}
}
};
/**
* 更新ListView数据
*/
private void updateListView()
{
String f[] = { "f_id", "f_name", "f_address", "f_cal"};
/* SELECT f[] FROM tables[0] */
Cursor c = dbHelper.select
更多精彩
赞助商链接