如何在android中将多行组合成一行具有相同的列值v1

时间:2017-08-18 04:23:25

标签: android android-sqlite

View_IDMAC_QR_Code在多行中很常见,但Button_ID不同。在检索View_ID时我想要的是它应该被视为单v1个,并且在图片点击事件中查看所有三个Button_ID
插入查询 enter image description here

 public void insertData(String view_id, String button_id, String publish_topic, String subscribe_topic, byte[] image, String qr_code){
    SQLiteDatabase database = getWritableDatabase();
    String sql = "INSERT INTO CONFIG VALUES (NULL, ?, ?, ?, ?, ?, ?)";

    SQLiteStatement statement = database.compileStatement(sql);
    statement.clearBindings();

    statement.bindString(1, view_id);
    statement.bindString(2, button_id);
    statement.bindString(3, publish_topic);
    statement.bindString(4, subscribe_topic);
    statement.bindBlob(5, image);
    statement.bindString(6, qr_code);


    statement.executeInsert();
}

从SQLite获取所有数据

  // get all data from SQLite
    Cursor cursor =sqLiteHelper.getData("SELECT * FROM CONFIG");
    GetAdapter1.clear();
    while (cursor.moveToNext()) {
        int id = cursor.getInt(0);
        String view_id = cursor.getString(1);
        String button_id = cursor.getString(2);
        byte[] image = cursor.getBlob(5);

        GetAdapter1.add(new GetAdapter(view_id, button_id, image, id));
    }

1 个答案:

答案 0 :(得分:0)

我正在研究它很长时间我在SQLite中看到我们必须使用select命令