android sqlite 查询数据库的总条数

  • Post author:
  • Post category:其他



	/**
	 * 查询数据库中的总条数.
	 * @return
	 */
	public long allCaseNum( ){
		String sql = "select count(*) from info";
		Cursor cursor = db.rawQuery(sql, null);
		cursor.moveToFirst();
		long count = cursor.getLong(0);
		cursor.close();
		return count;
	}

<span style="white-space:pre">	</span>/**
<span style="white-space:pre">	</span> * 查询数据库中的没有解决的条数.
<span style="white-space:pre">	</span> * @return
<span style="white-space:pre">	</span> */
<span style="white-space:pre">	</span>public long queryUndisposeCase( ){
<span style="white-space:pre">		</span>String sql = "select count(*) from info where handleStatus not in (?)";
<span style="white-space:pre">		</span>Cursor cursor = db.rawQuery(sql, new String []{"1"});
<span style="white-space:pre">		</span>cursor.moveToFirst();
<span style="white-space:pre">		</span>//获得某一列的长度
<span style="white-space:pre">		</span>long count = cursor.getLong(0);
<span style="white-space:pre">		</span>cursor.close();
<span style="white-space:pre">		</span>return count;
<span style="white-space:pre">	</span>}



版权声明:本文为agoodcoolman原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。