Hi everyone, problem I am facing is that whenever I download some picture from the server and save it to Application.dataPathPersistent it is invisible by Gallery on Android device. Don’t know why.
The other problem is, I am unable to Move or Copy that file to another location on Android device.
Did anyone encounter this kind of problem? All I want is to have possibility to save Picture on Android device and that picture is visible in the Gallery.
Code I am using so far is this:
private IEnumerator DownloadAndSave(string url)
{
WWW www = new WWW(url);
yield return www;
while (!www.isDone)
{
yield return null;
}
string savePath = Path.Combine(Application.persistentDataPath, Title + ".png");
byte[] bytes = www.bytes;
File.WriteAllBytes(savePath, bytes);
#if UNITY_ANDROID
string moveTo = savePath.Remove(savePath.IndexOf("Android/")) + "Download/" + Title + ".png";
StartCoroutine(MoveFile(savePath, moveTo));
#endif
}
IEnumerator MoveFile(string currentPath, string destinationPath)
{
yield return new WaitForSeconds(0.5f);
File.Copy(currentPath, destinationPath);
}