fix local database group inserting

This commit is contained in:
tibbi 2018-03-21 17:40:51 +01:00
parent 30d21625bf
commit b28e85727d
2 changed files with 8 additions and 4 deletions

View File

@ -395,7 +395,7 @@ class ContactsHelper(val activity: BaseSimpleActivity) {
fun createNewGroup(title: String, accountName: String, accountType: String): Group? {
if (accountType == SMT_PRIVATE) {
return activity.dbHelper.insertGroup(title)
return activity.dbHelper.insertGroup(Group(0, title))
}
val operations = ArrayList<ContentProviderOperation>()

View File

@ -145,10 +145,14 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
mDb.update(CONTACTS_TABLE_NAME, contactValues, selection, null)
}
fun insertGroup(group: Group): Boolean {
fun insertGroup(group: Group): Group? {
val contactValues = fillGroupValues(group)
val id = mDb.insert(GROUPS_TABLE_NAME, null, contactValues).toInt()
return id != -1
val id = mDb.insert(GROUPS_TABLE_NAME, null, contactValues)
return if (id == -1L) {
null
} else {
Group(id, group.title)
}
}
fun updateGroup(group: Group): Boolean {