Я пытаюсь сделать простой выбор, сравнивая значение поля моего приложения со значением в столбце таблицы, но не могу понять, как:
public class DatabaseHelper extends SQLiteOpenHelper
{
public static final String DATABASE_NAME = "warehousedata.db";
public static final String TABLE_NAME = "warehouse_data_table";
public static final String COL_1 = "ID";
public static final String COL_2 = "BARCODE";
public static final String COL_3 = "ARTNUMBER";
public static final String COL_4 = "PRODUCTGROUP";
public static final String COL_5 = "BINLOCATION";
public static final String COL_6 = "ACCOUNT";
public static final String COL_7 = "STATUS";
public static final String COL_8 = "APPROVED";
String barcodcheck;
public String getBarcodcheck() {
return barcodcheck;
}
public void setBarcodcheck(String barcodcheck) {
this.barcodcheck = barcodcheck;
}
public DatabaseHelper(@Nullable Context context) {
super(context, DATABASE_NAME, null, 1);
//SQLiteDatabase db = this.getWritableDatabase();
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("create table " + TABLE_NAME +" (ID INTEGER PRIMARY KEY AUTOINCREMENT, BARCODE TEXT, ARTNUMBER TEXT, PRODUCTGROUP TEXT, BINLOCATION TEXT, ACCOUNT TEXT, STATUS TEXT, APPROVED TEXT)");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS "+TABLE_NAME);
onCreate(db);
}
public Cursor getAllData() {
SQLiteDatabase db = this.getWritableDatabase();
//Cursor res = db.rawQuery("select * from "+TABLE_NAME,null);
Cursor res = db.rawQuery("select * from "+TABLE_NAME+" where "+COL_2.equals(barcodcheck), null, null);
return res;
}
}