我创建了一个MPAndroidChart,用于在Android Studio和SQLite数据库中按月将给定费用类别和组的费用汇总为一个字符串。除08和09以外,每个月都非常有效。我在这里还阅读了其他一些问题,说python中的08和09不是有效数字。我不确定这是否适用于SQLite。我已经尝试过尝试将字符串转换为整数或使用if语句都无济于事的所有方法。以下是适用于除08和09以外的所有月份的代码:请帮助!
这在我的dBHelper中:
// This method is for the CY Expense Category Breakdown Chart //
public ArrayList<BarEntry> cYExpenseCategoryBarEntries() {
String expense_sum_column = "expense_sum";
String month_column = "month";
String date = "strftime('%m',date)";
SQLiteDatabase db = this.getReadableDatabase();
String whereSelection = "expense >=0 AND income ISNULL AND expense_category=1 AND strftime('%Y',date)=strftime('%Y',date('now'))";
String[] columns = new String[]{"SUM(expense) AS " + expense_sum_column,date + " AS " + month_column};
Cursor csr = db.query("transactions",columns,whereSelection,null, date,null,null);
ArrayList<BarEntry> rv = new ArrayList<>();
while(csr.moveToNext()) {
rv.add(new BarEntry(
csr.getInt(csr.getColumnIndex(month_column)),
csr.getFloat(csr.getColumnIndex(expense_sum_column))
));
}
csr.close();
return rv;
}