我总结价格值的命令不起作用

时间:2017-01-04 15:44:57

标签: android

public ArrayList calculateTotal(){

    SQLiteDatabase db = this.getWritableDatabase();
    ArrayList<Integer> array_list2 = new ArrayList<Integer>();

    Cursor cursor1 = db.rawQuery(
            "SELECT SUM(cost) FROM expense", null);
    if (cursor1.moveToFirst()) {
        columntotal = cursor1.getFloat(0);
    }
    cursor1.close();
    db.rawQuery("INSERT INTO total VALUES(columntotal)", null);

我无法总结android studio中的费用和显示....

1 个答案:

答案 0 :(得分:0)

您的插入命令应如下所示:

"INSERT INTO total VALUES("+columntotal+")"

最好使用PreparadStatement approach