在我的应用程序中,我显示的数据来自数据库的表视图。我的要求是,从数据库我必须检索将在当月落入的数据。我写了查询,但它来了为0.实际上我今天的日期在数据库中有1项,所以我的查询应该返回该数据,但它显示为0.请帮助我。提前感谢。在android中的数据库检索
我的查询如下:
public String addgroupincome(String grp) throws SQLException
{
long sum=0;
Cursor cursor1 = db.rawQuery(
"SELECT SUM("+(KEY_TOTAL)+") FROM incomexpense WHERE date= Strftime('%Y-%m','now') AND category='Income' AND groups='"+grp+"'",null);
if(cursor1.moveToFirst())
{
sum = cursor1.getLong(0);
}
cursor1.close();
String housetotal=String.valueOf((long)sum);
return housetotal;
}
我得到的是总,并在表的布局atextview显示..
final String houtotal=db.addgroupincome(group1);
housetotal.setText(houtotal);
你检查了cursor1.getCount()吗? – 2012-08-01 04:56:45
没有尼克..我会.. – 2012-08-01 04:57:19
S尼克...它是作为1 .. – 2012-08-01 04:59:39