mercredi 29 avril 2015

copy sqlite database from assets folder to android persistentpath in unity3d

I have a squlite database in assets folder with name MyDatabse.s3db and I want to copy it to android Application.persistentdatapath. I have used the following code

string filepath = Application.persistentDataPath + "/MyDatabase.s3db";
if (!File.Exists (filepath))
{
WWW loadDB = new WWW("jar:file://" + Application.dataPath + "!/assets/MyDatabase.s3db");
Debug.Log("yield done");
while(!loadDB.isDone) {}
File.WriteAllBytes(filepath, loadDB.bytes);
Debug.Log("copy done");
}

The database is created in the Application.persistentDataPath path but it is empty.

Aucun commentaire:

Enregistrer un commentaire