Ringtone Preference not saving choice

前端 未结 6 607
梦如初夏
梦如初夏 2021-01-13 13:40

I have a ringtone preference in my app but when I select the tone I want, it does not get stored in the preference value. I can click the preference again and it will not sh

6条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-13 14:25

    I just had the same problem, but then I reviewed my codes, when I read the preference:

    SharedPreferences settings = 
    context.getSharedPreferences(PREF_FILE_NAME, Context.MODE_PRIVATE);
    

    Which is wrong, the correct solution is:

    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
    

    Hope it helps

提交回复
热议问题