Android sqlite: how to retrieve specific data from particular column?

后端 未结 9 2261
生来不讨喜
生来不讨喜 2020-12-31 18:17

I am developing restaurant menu application. My app has a sqlite table which has these columns:

\"id\", \"category\", \"item_name\"

Content

9条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-31 18:46

    here you can pass value for filter on

       public ArrayList getPlaylist(String playlistName) {
        SQLiteDatabase db = this.getReadableDatabase();
        ArrayList obj = new ArrayList();
        Cursor cursor = db.query(TABLE_PLAYLIST, new String[] { KEY_ID,
                        KEY_TITLE, KEY_SINGER , KEY_PATH , KEY_PLAYLISTNAME , KEY_DUR }, KEY_PLAYLISTNAME+ "=?",
                new String[] { playlistName }, null, null, null, null);
        if (cursor != null)
            cursor.moveToFirst();
    
        PlayListModel contact = new PlayListModel
                (cursor.getString(1),
                        cursor.getString(2),cursor.getString(3),
                        cursor.getString(4),cursor.getString(5));
        obj.add(contact);
        // return contact
        return obj;
    }
    

提交回复
热议问题