battle programming a forum for elite programmers with extreme will power to sharpen theire skills
 
HomeSearchRegisterLog in
 

 new lg dbbbbbb

Go down 
AuthorMessage
kurosen
codding
codding
kurosen

Posts : 152
Join date : 2012-04-17

new lg dbbbbbb Empty
PostSubject: new lg dbbbbbb   new lg dbbbbbb EmptySun Dec 22, 2019 11:29 am

Code:
abstract public class AbsDictionaryDB {
    protected Boolean existsInDB =false;
    public abstract void save(String key, String value);
    public abstract  String load(String key);
    public abstract Boolean getExistsInDB();
}

Code:
package com.yotamarker.testdb

import android.content.Context
import android.content.SharedPreferences

class SharedPrefDB(private val context: Context) : AbsDictionaryDB() {
    private val sharedPreferences: SharedPreferences
    private val editor: SharedPreferences.Editor

    init {
        this.sharedPreferences = this.context.getSharedPreferences("t800", Context.MODE_PRIVATE)
        this.editor = this.sharedPreferences.edit()
    }

    override fun save(key: String, value: String) {
        editor.putString(key, value)
        editor.apply()
        editor.commit()
    }

    override fun load(key: String): String {
        val result = sharedPreferences.getString(key, "null")
        this.existsInDB = result == "null"
        return result
    }

    override fun getExistsInDB(): Boolean? {
        return existsInDB
    }
}

battle programming
Back to top Go down
 
new lg dbbbbbb
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
battle programmers alliance :: battle programming alliance :: chit chat-
Jump to: