how to get the database value to a String array in android(sqlite Database)

后端 未结 3 1601
梦谈多话
梦谈多话 2020-12-14 04:42

I have a database name \"CUED\" (sqlite Android)it have a table HELLO which contain a column NAME I can get the value to String from that column. L

3条回答
  •  太阳男子
    2020-12-14 05:26

    This is my code that returns arraylist contains afield value:

    public ArrayList getAllPlayers() {
    
        SQLiteDatabase db = this.getReadableDatabase();
        Cursor cur = db.rawQuery("SELECT " + serailnumber + " as _id, " + title
                + " from " + table, new String[] {});
        ArrayList array = new ArrayList();
        while (cur.moveToNext()) {
            String uname = cur.getString(cur.getColumnIndex(title));
            array.add(uname);
    
        }
        return array;
    }
    

提交回复
热议问题