我想每周对变量“schritte”求和并将其保存在额外的数据库中
我创建了我的数据库:
db = openOrCreateDatabase("myDB", MODE_PRIVATE, null);
// db.execSQL("drop table schritte");
String create = "create table if not exists schritte(bewegung TEXT, dauer TEXT, sdf DATE Default (datetime('now','localtime')));";
db.execSQL(create);
并且有我出现数据库的方法
public void btnHandlerAnzeigen_Schritte(View v) {
textViewSQLSchritt.setText("");
Cursor cursor = db.rawQuery("select * from schritte", null);
if (cursor.moveToFirst()) {
do {
int schritte = cursor.getInt(0);
String dauer = cursor.getString(1);
String date = cursor.getString(2);
textViewSQLSchritt.append("Schritte: " + schritte + " " + dauer + "\n"
+ date + "\n\n");
} while (cursor.moveToNext());
}
//here i have tried to make a sum but Im unable to finish it
Cursor cursor2 = db.rawQuery("select strftime('%W',_id) as week, sum(value) as total from schritte GROUP BY week_of_year order by _id desc", null);
}