1

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.

Aditya Patil
  • 123
  • 1
  • 1
  • 9
  • why not integrate a small database? – sommmen Jun 10 '20 at 07:29
  • @sommmen can you elaborate ? I have not created/used any database for unity - android connection before. I have no idea how to do it, can i change values under it at runtime and access them through both unity and native android plugin ? – Aditya Patil Jun 10 '20 at 13:02
  • well i am still not really sure what you're doing here, maybe write out the process flow a bit more for me. but you can either link it all together in a remote database on a server somwhere, or use a file-based database system. Then you can pass the db file around (just like any normal file). There are even db's that work based on JSON like https://couchdb.apache.org/ (again not sure what your situation is) – sommmen Jun 10 '20 at 13:10

0 Answers0