I'm tying to get the data from sqLite from this table
db.execSQL("create table cabling(Code text, note text, lat text, lng text, teamColor text, jobType text, image1 text, image2 text, image3 text, image4 text, image5 text, cable text, assawer text, ankor text, mwaser text, building_no text)")
the return function is
@SuppressLint("Recycle")
override fun returnCabling(db: SQLiteDatabase): ArrayList<CablingData> {
val cur = db.rawQuery("select * from cabling", arrayOf())
val cabling = ArrayList<CablingData>()
cur.moveToFirst()
while (!cur.isAfterLast) {
cabling.add(
CablingData(
cur.getString(cur.getColumnIndex("Code")),
cur.getString(cur.getColumnIndex("note")),
cur.getString(cur.getColumnIndex("lat")),
cur.getString(cur.getColumnIndex("lng")),
cur.getString(cur.getColumnIndex("teamColor")),
cur.getString(cur.getColumnIndex("jobType")),
cur.getString(cur.getColumnIndex("image1")),
cur.getString(cur.getColumnIndex("image2")),
cur.getString(cur.getColumnIndex("image3")),
cur.getString(cur.getColumnIndex("image4")),
cur.getString(cur.getColumnIndex("image5")),
cur.getString(cur.getColumnIndex("cable")),
cur.getString(cur.getColumnIndex("assawer")),
cur.getString(cur.getColumnIndex("ankor")),
cur.getString(cur.getColumnIndex("mwaser")),
cur.getString(cur.getColumnIndex("building_no"))
)
)
AppLogger.log("cabling", cabling.toString())
cur.moveToNext()
}
cur.close()
return cabling
}
it's return
Couldn't read row 0, col 0 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.
but when I use this
val cur2 = db.rawQuery("select Code, note, lat, lng from cabling", arrayOf())
cur2.moveToFirst()
while (!cur2.isAfterLast) {
AppLogger.log("testststs", cur2.getString(cur2.getColumnIndex("Code")))
cur2.moveToNext()
}
it's work BUT if I write all of the element in select statement it is gonna crash
select Code, note, lat, lng, teamColor, jobType, image1, image2, image3, image4, image5, cable, assawer, ankor, mwaser, building_no from cabling
this statement above won't work
thank you all for helping
<3