I am working in unity and for offline database i choose sqlite database.
it is working fine in unity editor and Android Device as well,
but it does not work in ios devices.
i think the problem is in path or may be any file is missing for ios.
using UnityEngine;
using System;
using System.IO;
using System.Collections;
using System.Data;
using System.Text;
using Mono.Data.SqliteClient;
public class dbAccess : MonoBehaviour
{
private string connection;
private IDbConnection dbcon;
private IDbCommand dbcmd;
private IDataReader reader;
private StringBuilder builder;
public void OpenDB(string p)
{
Debug.Log("Call to OpenDB:" + p);
// check if file exists in Application.persistentDataPath
string filepath = Application.persistentDataPath + "/" + p;
if(!File.Exists(filepath))
{
Debug.LogWarning("File \"" + filepath + "\" does not exist. Attempting to create from \"" +
Application.dataPath + "!/assets/" + p);
// if it doesn't ->
// open StreamingAssets directory and load the db ->
WWW loadDB = new WWW("jar:file://" + Application.dataPath + "!/assets/" + p);
while(!loadDB.isDone) {}
// then save to Application.persistentDataPath
File.WriteAllBytes(filepath, loadDB.bytes);
}
//open db connection
connection = "URI=file:" + filepath;
Debug.Log("Stablishing connection to: " + connection);
dbcon = new SqliteConnection(connection);
dbcon.Open();
}
public void CloseDB(){
reader.Close(); // clean everything up
reader = null;
dbcmd.Dispose();
dbcmd = null;
dbcon.Close();
dbcon = null;
}
}