상속: IDisposable
예제 #1
0
    IEnumerator test()
    {
        var    store  = new sqlite3.Store();
        var    pf     = Application.platform;
        string dbPath = Application.streamingAssetsPath + "/res.db";

        if (pf == RuntimePlatform.Android)
        {
            var source = dbPath;

            dbPath = Application.persistentDataPath + "/res.db";
            //if (!File.Exists(dbPath))
            {
                log("copy: " + source + " to " + dbPath);
                var www = new WWW(source);
                yield return(www);

                if (www.isDone)
                {
                    log("res.db:" + www.size.ToString());
                    File.WriteAllBytes(dbPath, www.bytes);
                }
                else
                {
                    log("error:" + www.error);
                    yield break;
                }
            }
        }

        log("**********begin read db:" + dbPath);
        var err = store.Connect(dbPath, "1234567890123456");

        if (err != "")
        {
            log("!!!!!error:" + err);
            yield break;
        }

        for (var i = 0; i <= 3; i++)
        {
            var values = store.LoadFields("Role", "id=" + i.ToString(), "id", "Name", "RoleType");
            var s      = string.Format("\t{0}\t{1}\t{2}", values[0], values[1], values[2]);
            log(s);
        }
        log("**********end read db value ***********");
    }
예제 #2
0
    IEnumerator test()
    {
        var store = new sqlite3.Store();
        var pf = Application.platform;
        string dbPath = Application.streamingAssetsPath + "/res.db";
        if (pf == RuntimePlatform.Android)
        {
            var source = dbPath;

            dbPath = Application.persistentDataPath + "/res.db";
            //if (!File.Exists(dbPath))
            {
                log("copy: " + source + " to " + dbPath);
                var www = new WWW(source);
                yield return www;
                if (www.isDone)
                {
                    log("res.db:" + www.size.ToString());
                    File.WriteAllBytes(dbPath, www.bytes);
                }
                else
                {
                    log("error:" + www.error);
                    yield break;
                }
            }
        }

        log("**********begin read db:" + dbPath);
        var err = store.Connect(dbPath, "1234567890123456");
        if (err != "")
        {
            log("!!!!!error:" + err);
            yield break;
        }

        for (var i = 0; i <= 3; i++)
        {
            var values = store.LoadFields("Role", "id=" + i.ToString(), "id", "Name", "RoleType");
            var s = string.Format("\t{0}\t{1}\t{2}", values[0], values[1], values[2]);
            log(s);
        }
        log("**********end read db value ***********");
    }