From 04395be1e74db214786caebba18f9f6268bf640f Mon Sep 17 00:00:00 2001 From: shinriyo Date: Sat, 24 May 2014 21:49:11 +0900 Subject: [PATCH] tab to space I just cleaned up code. I'm afraid if the "StreamingAssets" can work on the Android device? I guess it is read only on the Android device. --- Assets/SqliteInit.cs | 74 +++++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 39 deletions(-) diff --git a/Assets/SqliteInit.cs b/Assets/SqliteInit.cs index 83c9a49..8fb3273 100644 --- a/Assets/SqliteInit.cs +++ b/Assets/SqliteInit.cs @@ -1,6 +1,4 @@ using System; - - using UnityEngine; using System.IO; using UnityORM; @@ -8,43 +6,41 @@ public static class SqliteInit { - public static DBEvolution Evolution; - - static bool alreadyInited = false; - - public static void InitSqlite(){ - - if(alreadyInited)return; - alreadyInited = true; - - Evolution = new DBEvolution( - Path.Combine(Application.persistentDataPath,"sample_data.db")); - - Evolution.RecreateTableIfHashDiffers = true;// You shoud set false when you release application to avoid suddon drop table. - - // Init table - Evolution.Evolute("SampleTable",// Traget table - new List(){ // These sql is executed at once. - @"CREATE TABLE SampleTable(id INTEGER,nickname TEXT,lastLogin INTEGER, score FLOAT);", - @"ALTER TABLE SampleTable ADD COLUMN age INTEGER;" - }); - - Evolution.Evolute("OtherTable", - new List(){ - @"CREATE TABLE OtherTable(key TEXT,val TEXT);", - @"INSERT INTO OtherTable VALUES ('a','b')" - }); - - Evolution.Evolute("UserData", - new List(){ - //@"CREATE TABLE UserData(id INTEGER PRIMARY_KEY,name TEXT,hoge TEXT); " - new SQLMaker().GenerateCreateTableSQL(ClassDescRepository.Instance.GetClassDesc()) + " " - }); - - - } - -} + public static DBEvolution Evolution; + static bool alreadyInited = false; + + public static void InitSqlite () + { + if (alreadyInited) + { + return; + } + alreadyInited = true; + string path = Application.dataPath + "/StreamingAssets"; + Evolution = new DBEvolution ( + //Path.Combine(Application.persistentDataPath,"sample_data.db")); + Path.Combine (path, "sample_data.db")); + Evolution.RecreateTableIfHashDiffers = true;// You shoud set false when you release application to avoid suddon drop table. + // Init table + Evolution.Evolute ("SampleTable",// Traget table + new List (){ // These sql is executed at once. + @"CREATE TABLE SampleTable(id INTEGER,nickname TEXT,lastLogin INTEGER, score FLOAT);", + @"ALTER TABLE SampleTable ADD COLUMN age INTEGER;" + }); + + Evolution.Evolute ("OtherTable", + new List (){ + @"CREATE TABLE OtherTable(key TEXT,val TEXT);", + @"INSERT INTO OtherTable VALUES ('a','b')" + }); + + Evolution.Evolute ("UserData", + new List (){ + //@"CREATE TABLE UserData(id INTEGER PRIMARY_KEY,name TEXT,hoge TEXT); " + new SQLMaker().GenerateCreateTableSQL(ClassDescRepository.Instance.GetClassDesc()) + " " + }); + } +}