如题,book2为表名 class为列名,sp为一个spinner传来的string值,方法用button直接点击实现,我想让查询的结果显示在activity的一个listview上
       public void Query(){ 
     String table =  "book2" ;    
     String selection = "class=?" ;  
     String[] selectionArgs = new  String[]{ "sp" };    
     Cursor c = sqliteDatabase.query(table, null, selection, selectionArgs, null, null, null, null );
    
     c.moveToFirst();  
     list.invalidateViews();
     c.close(); 
     }
报错为nosuchmathodexception  不知道怎么改,求大神教我

解决方案 »

  1.   

    我的资源里有做好的数据库查询Demo,如有需要,可以去下载
      

  2.   

    [code=javaLinkedList<ChatMsgEntity> persons = new LinkedList<ChatMsgEntity>();
    //Cursor c = queryTheCursor(  startID,  uid,  fid);

    String s="SELECT * FROM tb_friendmsg  where  " 
    +"   ( ( _to="+uid+" and send="+fid+" ) or ( _to="+fid+" and send="+uid+" )) "
    +"order by id desc limit "+loadcount+" offset 0 ";
           
    Cursor c = db.rawQuery(s, null);

            while (c.moveToNext()) {
             ChatMsgEntity person = new ChatMsgEntity();
             person.id = c.getInt(c.getColumnIndex("id"));
             person.send = c.getInt(c.getColumnIndex("send"));
             person._to=c.getInt(c.getColumnIndex("_to"));
             person.createTime = c.getString(c.getColumnIndex("createTime"));
             person.content = c.getString(c.getColumnIndex("content"));
             persons.add(person);
            }
            c.close();
            return persons;][/code]
    参考方法。