Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Wear - access mobile shared preferences

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?

like image 369
Rico.Kl Avatar asked Dec 19 '15 14:12

Rico.Kl


People also ask

How can I see shared preferences in Android?

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.

What does Android shared preferences do?

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.

Where are shared preferences stored Android?

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() .

Can we use SharedPreferences in Android?

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.


1 Answers

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!

like image 196
Michael Zhou Avatar answered Oct 20 '22 07:10

Michael Zhou