Blendester
Blendester

Reputation: 1653

How to access Unity settings from Java/Android?

I've a published game in Unity. Now I want to release an update with Java/Android instead.

The problem is that I want to import the existing game settings. In Unity docs is written:

On Android data is stored (persisted) on the device. The data is saved in SharedPreferences. C#/JavaScript, Android Java and Native code can all access the PlayerPrefs data. The PlayerPrefs data is physically stored in /data/data/pkg-name/shared_prefs/pkg-name.xml.

The question is that Unity saves data in which key? I tried:

SharedPreferences sharedPreferences = this.getSharedPreferences("com.mycompany.app", Context.MODE_PRIVATE);
Map<String, ?> allEntries = sharedPreferences.getAll(); // it returns nothing

also I tried to access that file:

File file = new File("/data/data/com.mycompany.app/shared_prefs/com.mycompany.app.xml");
boolean exists = file.exists(); // it doesn't exist

How to access Unity settings from Java/Android?

Upvotes: 0

Views: 1351

Answers (1)

Ivan Wooll
Ivan Wooll

Reputation: 4323

This is how you can take a look at the stored Shared Preferences for yourself.

  1. Open Android Studio and plug in a device with your installed game
  2. Find the tab at the bottom right of AS labelled "Device File Explorer"
  3. In the resulting folder structure navigate to data/data/your_package_name/shared_prefs

Upvotes: 2

Related Questions