无法写入打包空气中的 sqlite db

发布于 2024-12-27 19:48:29 字数 63 浏览 4 评论 0原文

我在IDE(FB)中运行时可以写入数据库,但打包完空气后,应用程序不会写入sqlite db,为什么?提前致谢。

I can write to db when running in IDE(FB), while after packaging a air, the app wont write to sqlite db, Why? Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

笑梦风尘 2025-01-03 19:48:29

可能的原因是您安装的 Air 应用程序无法解析 sqlite 文件的路径。

我通常做的是使用 File 类的静态公共属性之一来解析我的 sqlite 文件,例如。

databaseConnection = new SQLConnection();
databaseConnection.addEventListener(SQLEvent.OPEN, onOpen);
databaseConnection.addEventListener(SQLErrorEvent.ERROR, onError);               
databaseConnection.openAsync(File.applicationDirectory.resolvePath('mydb.sqlite'));

这里的关键位是 File.applicationDirectory.resolvePath('mydb.sqlite') 行,在本例中,AIR 将在应用程序安装的目录中查找名为 mydb.sqlite 的文件 -在您的开发环境中,这将与 bin-debug 文件夹(或您要编译到的任何文件夹)相同。

希望有帮助,如果没有的话,如果您可以发布您正在使用的代码,以及您遇到的错误,我会尽力进一步帮助您。

The likely cause is that your installed Air application can't resolve the path to your sqlite file.

What I normally do is to use one of the static public properties of the File class to resolve my sqlite file from eg.

databaseConnection = new SQLConnection();
databaseConnection.addEventListener(SQLEvent.OPEN, onOpen);
databaseConnection.addEventListener(SQLErrorEvent.ERROR, onError);               
databaseConnection.openAsync(File.applicationDirectory.resolvePath('mydb.sqlite'));

The key bit here is the File.applicationDirectory.resolvePath('mydb.sqlite') line, in this instance AIR will look for a file called mydb.sqlite in the directory that the application is installed into - in your development environment this would be the same as the bin-debug folder (or whatever folder you are compiling to).

Hope that helps, if not if you can post the code you are using , and what error you are getting I will try and help you further.

最舍不得你 2025-01-03 19:48:29

最可能的原因是您的数据库文件驻留在应用程序目录中,该目录是只读的。

来自 Flex 3.5 语言参考:

File.applicationDirectory - 安装应用程序的只读目录(以及任何已安装的资产)

如果是这种情况,一个可能但不仅仅是简单的解决方案是仅使用 File.applicationStorageDirectory。

希望这有帮助。

N。

The most likely reason is that your DB file resides in the application directory, which is read only.

From Flex 3.5 Language Reference:

File.applicationDirectory—the read-only directory where the application is installed (along with any installed assets)

If this is the case, a possible but not only easy fix would be to just use File.applicationStorageDirectory.

Hope this helps.

N.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文