Hello everyone.
Currently I’m writing an app which store xml and texture files in project folder. When I build the apk file, I know that the “StreamingAssets” folder that we see in project folder will be compressed into that single apk file.
However, right now I’m facing the issue that I can’t read those files in the that streamingassests in that apk file. Please be aware that I will both be reading and writing those xml and textures will be loaded in real time. I’ve done a quick search for solution, the result is suggesting copying files that will be “manipulated” from Application.streamingAssetsPath to Application.persistentDataPath. I’ve got that code working in Windows, but not in Android.
Regarding building info, MInimum API level is Android 4.1 “Jelly Bean” (API level 16), Device Filter is ARMv7 only, Graohics Level is OpenGL ES 2.0
According to this link, http://forum.unity3d.com/threads/183818-Android-Streaming-Assets, WWW class will be needed to load the streaming assets
the following is my code
IEnumerator assetFileManage_AND()
{
string[] xmlFilePath_AND = Directory.GetFiles(Application.streamingAssetsPath + "/xml/");
string[] xmlFileNamePath_AND = new string[xmlFilePath_AND.Length];
string[] texFilePath_AND = Directory.GetFiles(Application.streamingAssetsPath + "/Texture/");
string[] texFileNamePath_AND = new string[texFilePath_AND.Length];
for(int i=0;i<xmlFileNamePath_AND.Length;i++)
{
xmlFileNamePath_AND[i] = Path.GetFileName(xmlFilePath_AND[i]);
}
for(int x=0;x<texFileNamePath_AND.Length;x++)
{
texFileNamePath_AND[x] = Path.GetFileName(texFilePath_AND[x]);
}
for(int j=0; j<xmlFileNamePath_AND.Length;j++)
{
if(!File.Exists(Application.persistentDataPath + "/xml/" + xmlFileNamePath_AND[j]))
{
Debug.Log(xmlFileNamePath_AND[j] + " NOT exists------");
WWW sourceDataXML = new WWW(Application.streamingAssetsPath + "/xml/" + xmlFileNamePath_AND[j]);
yield return sourceDataXML;
File.Copy(sourceDataXML.text,
Application.persistentDataPath + "/xml/" + xmlFileNamePath_AND[j],
true);
} else
{
Debug.Log(xmlFileNamePath_AND[j] + " exists------");
}
}
for(int y=0; y<texFileNamePath_AND.Length; y++)
{
if(!File.Exists(Application.persistentDataPath + "/Texture/" + texFileNamePath_AND[y]))
{
Debug.Log(texFileNamePath_AND[y] + " NOT exists------");
WWW sourceDataTex = new WWW(Application.streamingAssetsPath + "/Texture/" + texFileNamePath_AND[y]);
yield return sourceDataTex;
File.Copy(sourceDataTex.text,
Application.persistentDataPath + "/Texture/" + texFileNamePath_AND[y],
true);
} else
{
Debug.Log(texFileNamePath_AND[y] + " exists------");
}
}
}
How should I modify my code to get that working?
Any help will be greatly appreciated.