import System.IO;
import System.Collections;
import System.Text;
import System.Data.Linq;
import Mono.Data.Sqlite;
import DbLinq;
static var databaseName : String = “my_db.sqlite”;
public class Database
{
var databasePath : String = "";
var dbcon : SqliteConnection;
var dbcmd : SqliteCommand;
var reader : SqliteDataReader;
public function OpenDB()
{
if(Application.platform == RuntimePlatform.IPhonePlayer)
{
databasePath = "URI=file:" + Application.persistentDataPath + "/" + databaseName;
}
else if(Application.platform == RuntimePlatform.Android)
{
databasePath = "URI=file:" + Application.persistentDataPath + "/" + databaseName;
Debug.Log("DB PATH : "+databasePath);
if(!File.Exists(databasePath))
{
Debug.Log("File " + databasePath + " does not exist.");
var path : String = "jar:file:" + Application.persistentDataPath + "!/assets/" + databaseName;
Debug.Log("CREATING DATABASE FROM : " + path);
var loadDB : WWW = new WWW (path);
while(!loadDB.isDone)
{
}
File.WriteAllBytes(databasePath, loadDB.bytes);
}
}
else
{
databasePath = "URI=file:" + databaseName;
}
//Debug.Log("Db Path : "+databasePath);
dbcon = new SqliteConnection(databasePath);
dbcon.Open();
}
}
When I run on android device ,
I got following error.
DirectoryNotFoundException: Could not find a part of the path “/URI=file:/data/app/com.test.myApp-1.apk/my_db.sqlite”.
04-09 16:41:00.235: I/Unity(23849): at System.IO.FileStream…cto…
Please help me…