所以我试图将 Imageview 保存到 sharedpreference 中,所以当用户从它自己的应用程序中选择图像时,如果有意义的话,图像将被保存并设置为 imageview id!当用户退出我的应用程序并重新打开它时,图像将与他保存的图像相同吗?
我尝试了这段代码,但它给了我错误,例如for input string " "
我的共享偏好
CompassBtn.setOnClickListener{
val prefCompass = getSharedPreferences("Drawable", Context.MODE_PRIVATE)
val editor = prefCompass.edit()
editor.putInt("ic_compass", ic_compass.setImageResource(R.drawable.ic_compass1).toString().toInt())
editor.commit()
}
**这就是我试图检索它的方式**
val prfCompass = getSharedPreferences("Drawable", Context.MODE_PRIVATE)
prfCompass.getInt("ic_compass", 0)
请提前帮助和感谢