Copy the shared preferences XML file from /data on Samsung device failed

前端 未结 6 785
粉色の甜心
粉色の甜心 2020-12-09 20:46

There\'s an exporting feature in my application. It\'s just a copy operation since all my settings are store in shared preference.

I just copy the xml file from /da

6条回答
  •  鱼传尺愫
    2020-12-09 21:14

    Never never never never never never never never never hardwire paths.

    Unfortunately, there's no getSharedPreferenceDir() anywhere that I can think of. The best solution I can think of will be:

    new File(getFilesDir(), "../shared_prefs")
    

    This way if a device manufacturer elects to change partition names, you are covered.

    Try this and see if it helps.

提交回复
热议问题