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

Unity3D如何使用Sqlite数据库

发布时间:2020-12-12 20:05:34 所属栏目:百科 来源:网络整理
导读:1,需要用到这几个dll文件: Mono.Data. Sqlite .dll 和 sqlite 3.dll和 Mono.Data.SQLiteClient.dll 2,将这几个dll文件放在Plugins下,必须放这里。 3,在Player Setting里的 OtherSettings里有个Optimization 下边的API Compatbility Level 选择.NET 2.0
01usingUnityEngine;02usingSystem.Collections;03usingSystem.Collections.Generic;04usingSystem;05usingSystem.Data;06usingMono.Data.SqliteClient;07usingSystem.Text;08usingSystem.IO;0910publicclassDBHelp : MonoBehaviour {11staticstringconn=string.Empty;12// Use this for initialization1314publicstaticstringgetConstr()//得到字符串15{161718#ifUNITY_EDITOR19conn ="URI=file:"+ Application.dataPath +"/StreamingAssets/KLandNG.db";20212223#elifUNITY_ANDROID242526conn ="URI=file:"+ Application.persistentDataPath +"/"+"daniya.db";2728#endif293031returnconn;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:

    推荐文章
      热点阅读