Created
December 13, 2020 12:29
-
-
Save vamsitallapudi/71ceb0daaacd9b4b4f18572abfcc8c64 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context | |
import android.os.Bundle | |
import android.widget.Button | |
import androidx.appcompat.app.AppCompatActivity | |
import com.coderefer.newyorktimesapp.R | |
class PrefActivity : AppCompatActivity() { | |
private val btnDarkMode: Button = Button(this) | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_pref) | |
btnDarkMode.setOnClickListener { | |
val sharedPreferences = getSharedPreferences("darkModePref", Context.MODE_PRIVATE) | |
val editor = sharedPreferences.edit() | |
editor.putBoolean("darkMode", true) | |
editor.apply() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment