mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-04-24 20:18:45 +02:00
remove the curly braces
This commit is contained in:
parent
f31d649f28
commit
73ce78d00d
@ -29,16 +29,16 @@ class DBHelper private constructor(private val mContext: Context) : SQLiteOpenHe
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreate(db: SQLiteDatabase) {
|
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)
|
insertFirstNote(db)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUpgrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
|
override fun onUpgrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
|
||||||
if (oldVersion < 2)
|
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)
|
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) {
|
private fun insertFirstNote(db: SQLiteDatabase) {
|
||||||
@ -66,12 +66,12 @@ class DBHelper private constructor(private val mContext: Context) : SQLiteOpenHe
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun deleteNote(id: Int) {
|
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 {
|
fun doesTitleExist(title: String): Boolean {
|
||||||
val cols = arrayOf(COL_ID)
|
val cols = arrayOf(COL_ID)
|
||||||
val selection = "${COL_TITLE} = ?"
|
val selection = "$COL_TITLE = ?"
|
||||||
val selectionArgs = arrayOf(title)
|
val selectionArgs = arrayOf(title)
|
||||||
var cursor: Cursor? = null
|
var cursor: Cursor? = null
|
||||||
try {
|
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)
|
val cols = arrayOf(COL_ID, COL_TITLE, COL_VALUE, COL_TYPE)
|
||||||
var cursor: Cursor? = null
|
var cursor: Cursor? = null
|
||||||
try {
|
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) {
|
if (cursor?.moveToFirst() == true) {
|
||||||
do {
|
do {
|
||||||
val id = cursor.getIntValue(COL_ID)
|
val id = cursor.getIntValue(COL_ID)
|
||||||
@ -107,7 +107,7 @@ class DBHelper private constructor(private val mContext: Context) : SQLiteOpenHe
|
|||||||
|
|
||||||
fun getNote(id: Int): Note? {
|
fun getNote(id: Int): Note? {
|
||||||
val cols = arrayOf(COL_TITLE, COL_VALUE, COL_TYPE)
|
val cols = arrayOf(COL_TITLE, COL_VALUE, COL_TYPE)
|
||||||
val selection = "${COL_ID} = ?"
|
val selection = "$COL_ID = ?"
|
||||||
val selectionArgs = arrayOf(id.toString())
|
val selectionArgs = arrayOf(id.toString())
|
||||||
var note: Note? = null
|
var note: Note? = null
|
||||||
var cursor: Cursor? = null
|
var cursor: Cursor? = null
|
||||||
@ -127,7 +127,7 @@ class DBHelper private constructor(private val mContext: Context) : SQLiteOpenHe
|
|||||||
|
|
||||||
fun updateNote(note: Note) {
|
fun updateNote(note: Note) {
|
||||||
val values = fillContentValues(note)
|
val values = fillContentValues(note)
|
||||||
val selection = "${COL_ID} = ?"
|
val selection = "$COL_ID = ?"
|
||||||
val selectionArgs = arrayOf(note.id.toString())
|
val selectionArgs = arrayOf(note.id.toString())
|
||||||
mDb.update(TABLE_NAME, values, selection, selectionArgs)
|
mDb.update(TABLE_NAME, values, selection, selectionArgs)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user