ошибка приложения сбоя:
java.lang.RuntimeException: невозможно запустить действие. ComponentInfo {com.example.notforgot / com.example.notforgot.MainActivity}: android.database.sqlite.SQLiteException: нет такого столбца: Описание (Sqlite code 1 SQLITE_ERROR): при компиляции: SELECT ID, заголовок, описание ОТ примечаний ГДЕ (заголовок как?) ORDER BY Title, (ошибка ОС - 2: такого файла или каталога нет)
некоторый код:
класс DbManager {
var dbName = "MyNotes"
var dbTable = "Notes"
var colID = "ID"
var colTitle = "Title"
var colDes = "Description"
var dbVersion = 1
val sqlCreateTable = "CREATE TABLE IF NOT EXISTS " + dbTable +" ("+colID+" INTEGER PRIMARY KEY,"+colTitle+" TEXT, "+colDes+ "TEXT);"
var sqlDB:SQLiteDatabase?=null
constructor(context: Context){
var db = DatabaseHelperNotes(context)
sqlDB = db.writableDatabase
}
inner class DatabaseHelperNotes:SQLiteOpenHelper{
var context: Context?=null
constructor(context: Context):super(context,dbName,null,dbVersion){
this.context = context
}
override fun onCreate(db: SQLiteDatabase?) {
if(db!=null)
db.execSQL((sqlCreateTable))
}
override fun onUpgrade(db: SQLiteDatabase?, oldVersion: Int, newVersion: Int) {
if(db!=null)
db.execSQL((dbTable))
}
}
fun insert(values:ContentValues):Long{
val ID =sqlDB!!.insert(dbTable,"",values)
return ID
}
fun Query(projection:Array<String>,selection:String,selectionArgs:Array<String>,sorOrder:String):Cursor{
val qb = SQLiteQueryBuilder();
qb.tables=dbTable
val cursor = qb.query(sqlDB, projection,selection,selectionArgs,null,null,sorOrder)
return cursor
}
fun delete (selection: String,selectionArgs: Array<String>):Int{
val count = sqlDB!!.delete(dbTable,selection,selectionArgs)
return count
}
fun updete(values: ContentValues,selection: String,selectionArgs: Array<String>):Int{
val count = sqlDB!!.update(dbTable,values,selection,selectionArgs)
return count
}
}
private fun LoadQuery(title: String) {
var dbManager = DbManager(this)
val projections = arrayOf("ID","Title","Description")
val selectionArgs = arrayOf(title)
val cursor = dbManager.Query(projections,"Title like ?",selectionArgs,"Title")
listNotes.clear()
if(cursor.moveToFirst()){
do{
val ID = cursor.getInt(cursor.getColumnIndex("ID"))
val Title = cursor.getString(cursor.getColumnIndex("Title"))
val Description = cursor.getString(cursor.getColumnIndex("Description"))
listNotes.add(Node(ID,Title,Description))
} while(cursor.moveToNext())
}
var myNotesAdapter = MyNotesAdapter(this,listNotes)
notesLv.adapter = myNotesAdapter
val total = notesLv.count
val mActionBar = supportActionBar
if(mActionBar != null){
mActionBar.subtitle = "You have $total note(s) in list"
}
}