加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Unity3D如何使用Sqlite数据库

发布时间:2020-12-12 23:55:24 所属栏目:百科 来源:网络整理
导读:1,需要用到这几个dll文件: Mono.Data.Sqlite.dll 和 sqlite3.dll和 Mono.Data.SQLiteClient.dll 2,将这几个dll文件放在Plugins下,必须放这里。 3,在Player Setting里的 OtherSettings里有个Optimization 下边的API Compatbility Level 选择.NET 2.0。 4
01using UnityEngine; 02using System.Collections; 03using System.Collections.Generic; 04using System; 05using System.Data; 06using Mono.Data.SqliteClient; 07using System.Text; 08using System.IO; 0910public classDBHelp : MonoBehaviour { 11staticstringconn=string.Empty; 12// Use this for initialization 1314publicstaticstringgetConstr()//得到字符串 15{ 161718#if UNITY_EDITOR 19conn = "URI=file:" + Application.dataPath + "/StreamingAssets/KLandNG.db"; 20212223#elif UNITY_ANDROID 242526conn ="URI=file:"+ Application.persistentDataPath +"/"+"daniya.db"; 2728#endif 293031returnconn; 32} 3334publicstaticboolUpdateScoll() 35{ 36inti = SqliteHelper.ExecuteNonQuery(getConstr(),CommandType.Text,37"update ItemInfo set name ='haha' where Type =1;"3839); 40returni > 0; 4142434445} 46}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

1,需要用到这几个dll文件:Mono.Data.Sqlite.dllsqlite3.dll和Mono.Data.SQLiteClient.dll

2,将这几个dll文件放在Plugins下,必须放这里。

3,在Player Setting里的 OtherSettings里有个Optimization 下边的API Compatbility Level 选择.NET 2.0。

4,添加个SQLiteHelper类。这个网上有,当然也可以自己写 - -!

5,数据库要放在StreamingAssets这个文件夹下。

5,剩下的就是操作了

随便写点代码:

[code]csharpcode:

    推荐文章
      热点阅读