我有一个(fillup_record)表我想要列出列名(Total_Cost)下的所有值,但是对于特定的汽车名称

时间:2017-02-02 23:29:10

标签: android sqlite

 public Double getCostt(String a) {
        openDatabase();
        Double price = null;
        Cursor cursor0=myDataBase.rawQuery("Select*FROM fillup_record WHERE Vehicle_Name='"+a+"'", null); //getting all values where vehicle name wi
  

在我的databasehelper类中,并为我的活动返回一个double值?提前感谢

        cursor0.moveToFirst();
        while (!cursor0.isAfterLast())
        {Cursor cursor = myDataBase.rawQuery("SELECT sum(Total_Cost) FROM fillup_record GROUP BY Vehicle_Name", null);
            price = Double.parseDouble(cursor.getString(3));
            cursor0.moveToNext();
        }
        cursor0.close();
        myDataBase.close();
        return price;
    }
}

0 个答案:

没有答案