remove the curly braces

This commit is contained in:
tibbi 2017-01-06 20:10:47 +01:00
parent f31d649f28
commit 73ce78d00d

View File

@ -29,16 +29,16 @@ class DBHelper private constructor(private val mContext: Context) : SQLiteOpenHe
}
override fun onCreate(db: SQLiteDatabase) {
db.execSQL("CREATE TABLE ${TABLE_NAME} (${COL_ID} INTEGER PRIMARY KEY, ${COL_TITLE} TEXT UNIQUE, ${COL_VALUE} TEXT, ${COL_TYPE} INTEGER DEFAULT 0, ${COL_PATH} TEXT)")
db.execSQL("CREATE TABLE $TABLE_NAME ($COL_ID INTEGER PRIMARY KEY, $COL_TITLE TEXT UNIQUE, $COL_VALUE TEXT, $COL_TYPE INTEGER DEFAULT 0, $COL_PATH TEXT)")
insertFirstNote(db)
}
override fun onUpgrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
if (oldVersion < 2)
db.execSQL("ALTER TABLE ${TABLE_NAME} ADD COLUMN ${COL_TYPE} INTEGER DEFAULT 0")
db.execSQL("ALTER TABLE $TABLE_NAME ADD COLUMN $COL_TYPE INTEGER DEFAULT 0")
if (oldVersion < 3)
db.execSQL("ALTER TABLE ${TABLE_NAME} ADD COLUMN ${COL_PATH} TEXT")
db.execSQL("ALTER TABLE $TABLE_NAME ADD COLUMN $COL_PATH TEXT")
}
private fun insertFirstNote(db: SQLiteDatabase) {
@ -66,12 +66,12 @@ class DBHelper private constructor(private val mContext: Context) : SQLiteOpenHe
}
fun deleteNote(id: Int) {
mDb.delete(TABLE_NAME, "${COL_ID} = $id", null)
mDb.delete(TABLE_NAME, "$COL_ID = $id", null)
}
fun doesTitleExist(title: String): Boolean {
val cols = arrayOf(COL_ID)
val selection = "${COL_TITLE} = ?"
val selection = "$COL_TITLE = ?"
val selectionArgs = arrayOf(title)
var cursor: Cursor? = null
try {
@ -87,7 +87,7 @@ class DBHelper private constructor(private val mContext: Context) : SQLiteOpenHe
val cols = arrayOf(COL_ID, COL_TITLE, COL_VALUE, COL_TYPE)
var cursor: Cursor? = null
try {
cursor = mDb.query(TABLE_NAME, cols, null, null, null, null, "${COL_TITLE} COLLATE NOCASE ASC")
cursor = mDb.query(TABLE_NAME, cols, null, null, null, null, "$COL_TITLE COLLATE NOCASE ASC")
if (cursor?.moveToFirst() == true) {
do {
val id = cursor.getIntValue(COL_ID)
@ -107,7 +107,7 @@ class DBHelper private constructor(private val mContext: Context) : SQLiteOpenHe
fun getNote(id: Int): Note? {
val cols = arrayOf(COL_TITLE, COL_VALUE, COL_TYPE)
val selection = "${COL_ID} = ?"
val selection = "$COL_ID = ?"
val selectionArgs = arrayOf(id.toString())
var note: Note? = null
var cursor: Cursor? = null
@ -127,7 +127,7 @@ class DBHelper private constructor(private val mContext: Context) : SQLiteOpenHe
fun updateNote(note: Note) {
val values = fillContentValues(note)
val selection = "${COL_ID} = ?"
val selection = "$COL_ID = ?"
val selectionArgs = arrayOf(note.id.toString())
mDb.update(TABLE_NAME, values, selection, selectionArgs)
}