这是我的方法Android的SQLite数据库没有返回
public int getamount(){
SQLiteDatabase db = this.getReadableDatabase();
Cursor c = db.rawQuery("SELECT SUM(buy) FROM " + table_name, null);
c.moveToFirst();
int i = c.getInt(c.getColumnIndex(col_6));
c.close();
return i;
}
这是我的主要活动
public void button_res(View view) {
if (view == findViewById(R.id.textView7)) {
total();
}
}
public void total(){
Integer i = myDb.getamount();
textView7.setText(i);
Toast.makeText(getApplicationContext(),i,Toast.LENGTH_LONG).show();
}
当我点击我的按钮,它显示了我什么。
我想'total'不会被调用;但这里没有人知道你是如何连接'button_res'的。 –