If I want to distribute a file or database with my application, where do I store that?
I would guess Asset folder but do not really know?
If I want to distribute a file or database with my application, where do I store that?
I would guess Asset folder but do not really know?
Regular assets are packed and not accessible separately in builds.
You want to put them in StreamingAssets, which will just get copied to the build.
Exactly what @Adrian says above. Here is how to get the path:
// alas it seems that Unity apparently still requires us to know this...
// reference: https://docs.unity3d.com/Manual/StreamingAssets.html
static string StreamingAssetPathForReal()
{
#if UNITY_EDITOR
return "file://" + Application.dataPath + "/StreamingAssets/";
#elif UNITY_ANDROID
return "jar:file://" + Application.dataPath + "!/assets/";
#elif UNITY_IOS
return "file://" + Application.dataPath + "/Raw/";
#endif
}
NOTE: for Android it is often necessary to open the file as above, then read it and write the data back into a regular file located here:
That file will be accessible to things like MySQL that cannot access things through the streaming assets interface. It means that if you have a 50mb database in your APK, you now have to copy it out and write it to another place on the user’s phone, requiring yet another 50mb of space, which kinda sucks, but that’s what we get for digitally-signed assets like APKs.