简体   繁体   中英

How to link shared preference with apk?

I build an android app where I'm using shared preference to store data. When I'm editing the data from the app it works fine for my device. But if I share the apk with another device, the data of shared preference for that device remains the default value, not the edited one. So, what can I do to edit data from the app then share the apk with anothe device so that it gets the edited data? (I'm very new to android)

I think you have misunderstood the concept of Shared preference as it is used to store data inside app.

Shared preference is similar to local db. It stores data like name-value pair. Means it stores data in your app's internal storage permanently until you clear data or uninstall app. If you want to share data between devices then use web server based on unique id for ex: device id of the phone.

Shared Preferences are stored locally in each device, you can't do this like changing the value and then pass the apk and would get the updated value.

For this you need to store the required value in cloud or server, so each time you will get the updated value, which will be fetched from the server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM