I'm using SharedPreferences on my mobile app to save data (e.g. for creating a recycler view list from that data)
Now I added a wear module and I'm trying to get the same list on my wear device. Is it able to access the shared preferences on my mobile from my wear device?
If your answer is no, what is the best alternative?
Open the device monitor by clicking it. Then you need to select the File Explorer tab in the device monitor. Find the data folder and find another data folder inside it. It will contain a folder having the name of your application package and there will be the desired SharedPreferences.
A SharedPreferences object points to a file containing key-value pairs and provides simple methods to read and write them. Each SharedPreferences file is managed by the framework and can be private or shared. This page shows you how to use the SharedPreferences APIs to store and retrieve simple values.
Android stores Shared Preferences settings as XML file in shared_prefs folder under DATA/data/{application package} directory. The DATA folder can be obtained by calling Environment. getDataDirectory() .
Android provides many ways of storing data of an application. One of this way is called Shared Preferences. Shared Preferences allow you to save and retrieve data in the form of key,value pair.
You should consider the wearable module as a separate application.
The wearable application is not capable of reading the SharedPreferences of your mobile application.
If you want to share data between your mobile and wearable applications you need to sync the data with Data Layer Api.
Hope it will help!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With