判断数据库是否为空和总条数

版权声明:原创文章,欢迎转载,转载请注明出处 https://blog.csdn.net/li7032/article/details/76032964


  
    String sql = "select count(*) from info";  
    Cursor cursor = db.rawQuery(sql, null);  
    cursor.moveToFirst();  
    long count = cursor.getLong(0);  // cursor.getCount();  根据Count判断是否为空
    cursor.close(); 

count = cursor.getLong(0);获取的是条目的数量
    cursor.getCount(); 获取的是行数
      

猜你喜欢

转载自blog.csdn.net/li7032/article/details/76032964