How can i check to see if my sqlite table has data in it?

后端 未结 13 1728
情话喂你
情话喂你 2020-12-01 13:14

EDIT, Changed the code slightly based on answers below, but still haven\'t got it working. I also added a log message to tell me if getCount was returning > 0, and i

13条回答
  •  情书的邮戳
    2020-12-01 13:37

    for java programs this worked for me:

        ResultSet rst = stm.executeQuery("SELECT * from Login");
               int i = 0;
               while(rst.next()){
                   ++i;
                   System.out.println(i);
               }
               System.out.println(i);
               if(i<1){
                   //No data in the table
               }
               else{
                   //data exists
               }
    

提交回复
热议问题