how to get count column

Posted by soclose on Stack Overflow See other posts from Stack Overflow or by soclose
Published on 2010-05-12T09:20:35Z Indexed on 2010/05/12 9:24 UTC
Read the original article Hit count: 217

Filed under:
|

Hi

I'd like to get the value of Count column from cursor.

public Cursor getRCount(String iplace) throws SQLException
{
 try {
      String strSql = "SELECT COUNT(_id) AS RCount FROM tbName WHERE place= '" + iplace + "'";            
      return db.rawQuery(strSql, null);
    } catch (SQLException e) {
        Log.e("Exception on query", e.toString());
        return null;
    }
} 

I tried to get this count column value from cursor like below

Cursor cR = mDbHelper.getRCount(cplace);if (cR.getCount() > 0){long lCount = cR.getLong(0);}cR.close();}

I got the debug error. How to get it?

© Stack Overflow or respective owner

Related posts about cursor

Related posts about .NET