SharedPreferences return only default value

后端 未结 3 1381
一整个雨季
一整个雨季 2021-01-19 13:15

So instead of creating a database, I\'m storing the data using SharedPreference.

My code is below:

   SharedPreferences.Editor editor =          


        
3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-19 14:05

    See docs about getPrefernces method:

    Retrieve a SharedPreferences object for accessing preferences that are private to this activity.

    So, if you want to share preferences between activities you should use getSharedPreferences with specified name.

提交回复
热议问题