- Home /
Download and save images into local phone storage makes the app hang
Hi I wrote a game and the app can download images from server and then store them inside Application.persistentDataPath.
My problem is when saving few images the scene is hang and when it is done saving, it executes the rest of the codes.
How to solve this issue?
Saving image into device local storage:
if (File.Exists (Application.persistentDataPath + "/LayoutImages/")) {
Debug.Log (imagesPathPrefix + " already exists.");
return;
}
File.WriteAllBytes (Application.persistentDataPath + "/LayoutImages/abc.jpg", image);
How to solve this issue?
Try to place it in a function and start it as a coroutine
I just learn that coroutines are not multi-threaded, they run on the same thread as the regular scripts.
Answer by felixwcf85 · May 16, 2015 at 04:11 PM
I "solved" it. The app will hang when run on computer when it downloads and saves the images in Application.persistentDataPath. If I build and run the app in my phone, it will not hang when doing the same job under the same scripts.
Feel awkward and unpleasant even though it's not an issue anymore...
Your answer
Follow this Question
Related Questions
Download and save files to local? 1 Answer
Write Downloaded AssetBundle to Local Storage 4 Answers
Saving Local Data through WWW 1 Answer
Storing large files locally 2 Answers
Accessing the computer's local files 1 Answer