1、SQLite随机取n行数据,可加自己的条件
SELECT * FROM TableName WHERE key ? ORDER BY RANDOM() LIMIT 0,Num;
http://www.cnblogs.com/macroxu-1982/archive/2012/10/27/2742127.html
SELECT * FROM LanguageMoudle_Word WHERE Word LiKE 'ab%'
3、拷贝 streamasset 目录下的资源 like db 到不同平台的持久路径下
#region if ( GUI.Button(new Rect (170,10,150,70), "Run SQLite Test for streamingAssets db which moved to persistentDataPath") ) { db = new SQLiteDB(); log = ""; string dbfilename = "test.db"; byte[] bytes = null; #if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX string dbpath = "file://" + Application.streamingAssetsPath + "/" + dbfilename; log += "asset path is: " + dbpath; WWW www = new WWW(dbpath); Download(www); bytes = www.bytes; #elif UNITY_WEBPLAYER string dbpath = "StreamingAssets/" + dbfilename; log += "asset path is: " + dbpath; WWW www = new WWW(dbpath); Download(www); bytes = www.bytes; #elif UNITY_IPHONE string dbpath = Application.dataPath + "/Raw/" + dbfilename; log += "asset path is: " + dbpath; try{ using ( FileStream fs = new FileStream(dbpath, FileMode.Open, FileAccess.Read, FileShare.Read) ){ bytes = new byte[fs.Length]; fs.Read(bytes,0,(int)fs.Length); } } catch (Exception e){ log += " Test Fail with Exception " + e.ToString(); log += " "; } #elif UNITY_ANDROID string dbpath = Application.streamingAssetsPath + "/" + dbfilename; log += "asset path is: " + dbpath; WWW www = new WWW(dbpath); Download(www); bytes = www.bytes; #endif if ( bytes != null ) { try{ string filename = Application.persistentDataPath + "/demo_from_streamingAssets.db"; // // // copy database to real file into cache folder using( FileStream fs = new FileStream(filename, FileMode.Create, FileAccess.Write) ) { fs.Write(bytes,0,bytes.Length); log += " Copy database from streaminAssets to persistentDataPath: " + filename; } // // initialize database // db.Open(filename); log += " Database created! filename: " + filename; Test2(db, ref log); } catch (Exception e){ log += " Test Fail with Exception " + e.ToString(); log += " Did you copy test.db into StreamingAssets ? "; } } } #endregion