public void viewAll() {
btnHighScore.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View view) {
Cursor res = myDb.getAllData();
if(res.getCount() == 0) {
showMessage("Error", "Nothing found");
return;
}
StringBuffer buffer = new StringBuffer();
while(res.moveToNext()) {
buffer.append("ID : " + res.getString(0) + "\n");
buffer.append("Firstname : " + res.getString(1) + "\n");
buffer.append("Lastname : " + res.getString(2) + "\n");
}
showMessage("High Score Table", buffer.toString());
}
}
);
}
public void showMessage(String title, String message) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setCancelable(true);
builder.setTitle(title);
builder.setMessage(message);
builder.show();
}
您可以在此处查看完整的代码:SQLite App
我无法查看保存在数据库中的数据。我将代码上传到这里,以便有人帮助我发现我犯的错误,因为我没有收到任何错误。
答案 0 :(得分:1)
根据链接中的代码,您需要从视图中获取名字和姓氏。参见第142行。在// $themes = Theme list array [id => theme-name, id => theme-name]
// $active_theme = Record of "active_theme" with value equal to "1"
// $extra = Custom HTML attributes e.g. class="something" onclick="function(js)"
echo form_dropdown('site_color_theme', $themes, $active_theme, $extra);
中获取名称值的视图为空,因此您将空字符串插入数据库。
this.zone