I made a cross matching words game for Android devices. Currently I am using an SQLite Database in StreamingAssets folder for the words in the game and everything works great.
The problem is that my database in StreamingAssets folder is easily accessible to anyone.
Is there any way to move and access my database from other folder except StreamingAssets?
I am using the code below to access my database on Android:
string databaseName = "/MyDatabase.db";
StartCoroutine(SetDatabase(databaseName));
return Path.Combine("URI=file:" + Application.persistentDataPath + databaseName);
private IEnumerator SetDatabase(string databaseName)
{
string path = Path.Combine("jar:file://" + Application.dataPath + "!/assets" + databaseName);
UnityWebRequest unityWebRequest = UnityWebRequest.Get(path);
yield return unityWebRequest.SendWebRequest();
while (!unityWebRequest.isDone) { }
if (unityWebRequest.isNetworkError || unityWebRequest.isHttpError)
AppHelper.Dbg("SetDefinitionsDatabaseForAndroid()", this + ": " +unityWebRequest.error);
/// Retrieve results as binary data.
byte[] data = unityWebRequest.downloadHandler.data;
/// Writes the DB in the persistent memory.
File.WriteAllBytes(Path.Combine(Application.persistentDataPath + databaseName), data);
}