0
我有一個表中有一列,我已經設置該列的值默認爲0;但每當我訪問該值,它無法訪問。下面的代碼,我已經嘗試過。Android數據庫提取數據庫值
public void getmaxoid() {
SQLiteDatabase database = dataforcategorylistview.getReadableDatabase();
String[] columns = {"order_id"};
Cursor cursors = database.rawQuery("Select max(order_id) from sales_item", null);
if (cursors.moveToNext()) {
convertedorderid = cursors.getInt(cursors.getColumnIndexOrThrow("order_id"));
if (convertedorderid==0) {
int oid = 0;
//int oid = Integer.parseInt(OrderIdFromService);
serverorderid = String.valueOf(convertedorderid++);
orderidset.setText(serverorderid);
} else {
serverorderid = String.valueOf(convertedorderid++);
orderidset.setText(serverorderid);
}
cursors.close();
}
} And this is my table:
String salesitem = "CREATE TABLE `sales_item` (`sales_id` integer NOT NULL,`order_id` numeric DEFAULT 0,`menu_id` nvarchar(500) NOT NULL,`qty` integer NOT NULL,`rate` numeric NOT NULL,`total_amount` numeric NOT NULL,`w_id` numeric NOT NULL,`kot_id` integer NOT NULL,PRIMARY KEY(`sales_id`))";
感謝您提供解決方案 – Dipak