- Home /
Question by
$$anonymous$$ · Oct 19, 2016 at 06:38 AM ·
c#unity 5externalinternalwrite data
Problem with Write Access
Hello,
I'm developing an app using SQLite database and i had some issues with access this db on Android, but i got it and it works. The problem now is that my app is crashing whenever i try to run it on my device or any other device (sometimes it works). BUT i think i found the root of the problem. When i try to do the build with "Write Access" -->"External (SD Card)" the app crashes, but when i build with "Write Access" --> "Internal Only" the app does not crashes anymore, but i also can not acces the database and i have no idea why it happens.
the code blocks below where working just fine after the change mentioned:
here i copy the db to Android persistentDataPath folder:
void Awake()
{
filePath = Application.persistentDataPath + "/MGDB.db";
Debug.Log (filePath);
//print(filePath);
//if(!File.Exists(filePath))
//{
loadDB = new WWW("jar:file://" + Application.dataPath + "!/assets/MGDB.db");
while (!loadDB.isDone)
{
}
File.WriteAllBytes(filePath, loadDB.bytes);
//}
}
and here i connect to the db:
if (Application.platform == RuntimePlatform.Android)
{
connection = (IDbConnection)new SqliteConnection("URI=file:" + Application.persistentDataPath + "/MGDB.db");
connection.Open();
command = connection.CreateCommand();
//print("android");
}
Have you any idea about this anomaly?
Comment