How to make a connection of Unity player prefs and Android sharedPreferences?

333 views Asked by At

Im using Unity android where i have used a native android plugin, I want to pass a json file to and from unity and Android plugin.

I was previously using string contents = (File.ReadAllText(Application.persistentDataPath + "/contents.json")); in unity to read from the json which is stored in external storage INTERNAL STORAGE/Android/data/<packagename>/files/ Also i was reading the contents.json from android plugin by File file_name=context.getExternalFilesDir("contents.json") ; and it worked well.

But then I realised that the json can be seen from the android devices file manager and other apps and thus can be tampered, so this method isnt secure at all.

So I was thinking whether we can use Player Prefs and shared preferences , where I can save my json as a string in player prefs from unity and the android plugin can access it and visa-versa. Im not sure if this is possible or is there any other alternative? I want to do this all at runtime.

Additional info: Im doing this because i want to keep updating the json form unity at runtime and then access this updated json from android plugin.

0

There are 0 answers