Ниже приведен запрос на создание таблицы
Код: Выделить всё
database.execSQL("CREATE TABLE IF NOT EXISTS ReaderFlag ("
+ "id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,"
+ "reader_customer_id INTEGER NOT NULL,"
+ "reader_route_id INTEGER NOT NULL,"
+ "start_end_flag TEXT NOT NULL);");
Код: Выделить всё
fun uploadFlagToCustomer(
database: SQLiteDatabase,
flags: List
) {
flags.forEach { action ->
//val action = flags.get(0)
var flagString = ""
if (action.start) {// converting boolean to string
flagString = "start"
}
if (action.stop) {// converting boolean to string
flagString = "stop"
}
/* val contentValue = ContentValues()
contentValue.put(ReaderTable.startEndFlag, flagString)
contentValue.put(ReaderTable.customerID, action.customer)
contentValue.put(ReaderTable.routeID, action.route)
contentValue.put(ReaderTable.customer_address, action.address.trim())*/
val address = "\"${action.address.trim()}\""
val flagUnit = "\"${flagString}\""
System.out.println("flagvalue $flagString, ${action.customer}, ${action.route}, ${action.address}")
val query = "INSERT INTO $Reader_Table (${ReaderTable.customerID}, ${ReaderTable.routeID}, ${ReaderTable.startEndFlag}) VALUES (${action.customer}, ${action.route}, $flagUnit)"
val error = database.execSQL(query)
System.out.println("errorinsert1: $error, $query")
/* try {
val error:Long = database.insertOrThrow(
Reader_Table,
null,
contentValue
)
System.out.println("errorinsert1: $error")
}catch (e: SQLiteException){
System.out.println("errorinsert2: $e")
}catch (er: SQLiteAbortException){
System.out.println("errorinsert3: $er")
}*/
}
}
Код: Выделить всё
data class StartStopPremisesFlag(
val customer: Int,
val route: Int,
val address: String,
var start: Boolean,
var stop: Boolean)
Подробнее здесь: https://stackoverflow.com/questions/791 ... es-are-not