开发者

SQLite table query

I query the table by using this function below

   public Cursor getTableInfo() throws SQLException 
{            
 return db.query(TableName, null, 
            null, 
            null, 
            null, 
            null, 
            null);
}

I got the error "View Root.handleMessage(Message)line:1704". I could insert the data but can't query the data. I called this function below

      Cursor c = db.getTableInfo开发者_Go百科();
      int cRow = c.getCount();
      if (cRow == 0)
      {
       Toast.makeText(NewContact.this, 
                "No Record",                 
                Toast.LENGTH_LONG).show();
      }

In SQLite, is there any case-sensitive in the name of database, table, column?

Please help me.


Your db request looks ok and it should return all records from your table. So maybe there are just no records in the table?

Also it's unclear whether you have problem with db related stuff or with smth else, because the code provided looks ok.


I would rather evaluate the outcome of c.moveToFirst() instead of c.getCount(). The latter means the cursor iterates over the whole dataset which is a more costly operation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜