Android Persistent Data loading fails

Hey Everyone,

I’m struggling with a problem for a couple of days now, I’m making an app in which the user can take pictures with an AR layer
and save them to a gallery for mobile devices.

To keep track of these pictures I make xml files with all the info the user enters and save this and the picture (which I take through a ReadPixels because I don’t want my GUI in the picture) to the Application.persistentDataPath

This works perfectly in editor and iOS, but the Android version fails completely.
Every time I try to load something it returns the error :
* java.lang.NullPointerException: Cannot find “!/”

The address that I’m trying to open is: * jar:file:///data/data/ *

but neither the png or the txt loads and I have no idea why. I think the saving works which just saves it with fileStreamer to

  • /data/data/ * and I try loading it with a WWW, but that doesn’t seem to work.

It’s very confusing to find good information about the persistentdatapath and how to properly load from it and some say you have to add a prefix:

		string path;
		path = "file:" + Application.persistentDataPath;
		path = "jar:file://"+ Application.persistentDataPath;
		#elif UNITY_IOS
		path = "file:" + Application.persistentDataPath;
		//Desktop (Mac OS or Windows)
		path = "file:"+ Application.persistentDataPath;

upon which I combine it with Path.Combine(path, fileName);
And while this is the case for iOS, it hasn’t worked so far I tried on Android and it’s driving me nuts. I’ve tried it without the prefix, I’ve tried it with “jar:file/”. Nothing seems to work, making me question this is even possible in Unity.

Is there something that has to be added to the manifest or changed in the player settings?

Please help, I’m losing too much time on this.

Alright after trying it without the prefix, I got a different error, pointing me to someone else’s solution, so I’m stating it here for anyone who’s struggling with it.

if you want to load from persistent data on Android add the prefix:

		path = "file:///"+ Application.persistentDataPath;

This could be information that should best be added to the script reference.