当前位置: 首页 > news >正文

SQLite4Unity3d安卓 在手机上创建sqlite失败解决

总结

要在Unity上运行一次出现库,再打包进APK内

问题

使用示例代码的创建库 

var dbPath = string.Format(@"Assets/StreamingAssets/{0}", DatabaseName);
#else// check if file exists in Application.persistentDataPathvar filepath = string.Format("{0}/{1}", Application.persistentDataPath, DatabaseName);if (!File.Exists(filepath)){Debug.Log("Database not in Persistent path");// if it doesn't ->// open StreamingAssets directory and load the db ->#if UNITY_ANDROIDvar loadDb = new WWW("jar:file://" + Application.dataPath + "!/assets/" + DatabaseName);  // this is the path to your StreamingAssets in androidwhile (!loadDb.isDone) { }  // CAREFUL here, for safety reasons you shouldn't let this while loop unattended, place a timer and error check// then save to Application.persistentDataPathFile.WriteAllBytes(filepath, loadDb.bytes);
#elif UNITY_IOSvar loadDb = Application.dataPath + "/Raw/" + DatabaseName;  // this is the path to your StreamingAssets in iOS// then save to Application.persistentDataPathFile.Copy(loadDb, filepath);
#elif UNITY_WP8var loadDb = Application.dataPath + "/StreamingAssets/" + DatabaseName;  // this is the path to your StreamingAssets in iOS// then save to Application.persistentDataPathFile.Copy(loadDb, filepath);#elif UNITY_WINRTvar loadDb = Application.dataPath + "/StreamingAssets/" + DatabaseName;  // this is the path to your StreamingAssets in iOS// then save to Application.persistentDataPathFile.Copy(loadDb, filepath);#elif UNITY_STANDALONE_OSXvar loadDb = Application.dataPath + "/Resources/Data/StreamingAssets/" + DatabaseName;  // this is the path to your StreamingAssets in iOS// then save to Application.persistentDataPathFile.Copy(loadDb, filepath);
#elsevar loadDb = Application.dataPath + "/StreamingAssets/" + DatabaseName;  // this is the path to your StreamingAssets in iOS// then save to Application.persistentDataPathFile.Copy(loadDb, filepath);#endifDebug.Log("Database written");}var dbPath = filepath;
#endifconnectionSQL = new SQLiteConnection(dbPath, SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create);Debug.Log("Final PATH: " + dbPath);

去到指定位置发现库创建失败,或者说没有这个库 

 

此时无库 

 

解决

点击运行后 

等待5秒左右,出现库,关停程序

再次打包,导入

库出现了!

http://www.lryc.cn/news/192934.html

相关文章:

  • 跨站请求伪造:揭秘攻击与防御
  • matlab 图像均值滤波
  • P1433 吃奶酪
  • c++string类的赋值问题
  • 服务器中了mkp勒索病毒怎么办?mkp勒索病毒特点,解密数据恢复
  • 深入探析网络代理与网络安全
  • 如何开始使用 Kubernetes RBAC
  • 8.简易无线通信
  • 渗透测试漏洞挖掘技巧
  • Nginx - 反向代理与负载均衡
  • Linux网络编程系列之UDP组播
  • 设计模式~状态模式(state)-23
  • linux环境下使用lighthouse与selenium
  • NeuroImage | 右侧颞上回在语义规则学习中的作用:来自强化学习模型的证据
  • uni-app编程checkbox-group获取选中的每个checkbox的value值
  • 数组——螺旋矩阵II
  • 反范式化设计
  • CCF CSP认证 历年题目自练Day31
  • PCL点云处理之从两片点云中获取具有匹配关系的同名点对 (二百一十八)
  • MySQL Row size too large (> 8126)
  • HUAWEI(26)——防火墙双机热备
  • 【ArcGIS】NDVI估算植被覆盖度FVC
  • vscode用密钥文件连接ssh:如果一直要输密码怎么办
  • 【AI视野·今日Robot 机器人论文速览 第五十三期】Thu, 12 Oct 2023
  • 【LeetCode第115场双周赛】100029. 和带限制的子多重集合的数目 | 前缀和背包 | 中等
  • ArcGIS笔记5_生成栅格文件时保存报错怎么办
  • YOLO目标检测——跌倒摔倒数据集【含对应voc、coco和yolo三种格式标签】
  • uniapp小程序实现绘制内容,生成海报并保存截图(Painter和Canvas两种方式举例)
  • HTTPS双向认证及密钥总结
  • Mybatis用Byte[]存图片,前端显示图片