简体   繁体   English

iOS存储SQLite数据库

[英]iOS storing SQLite database

I'm working on an app for iPad that uses a SQLite database.我正在开发一个使用 SQLite 数据库的 iPad 应用程序。 I am fairly far along in the development and now I'm trying to solve a problem of how to configure the app so that the database when it is on the iPad can be seen in the Files app.我在开发过程中已经走了很远,现在我正在尝试解决如何配置应用程序的问题,以便可以在文件应用程序中看到 iPad 上的数据库。 I have this app that I use named "Accounts2" and in Files on the iPad I can see its database in its own folder.我有一个名为“Accounts2”的应用程序,在 iPad 上的文件中,我可以在它自己的文件夹中看到它的数据库。

So far I've added the key "Application supports iTunes file sharing" to my info.plist and I can see the file in iTunes and drag the file off to my local disk.到目前为止,我已经将“应用程序支持 iTunes 文件共享”的键添加到我的 info.plist 中,我可以在 iTunes 中看到该文件并将该文件拖到我的本地磁盘上。 Now I'd like to understand what changes I need to make to be able to see the database file in the Files app..现在我想了解我需要进行哪些更改才能在“文件”应用程序中查看数据库文件。

Also, in the app I've defined the location of the database as being at:此外,在应用程序中,我已将数据库的位置定义为:

let databaseFolder = (NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as NSString) as String

Working with a breakpoint running the app on the iPad I see that the path above has translated to the following使用在 iPad 上运行应用程序的断点我看到上面的路径已转换为以下内容

/var/mobile/Containers/Data/Application/C3079EB8-2190-4161-A5E4-ABFFB3374393/Documents /var/mobile/Containers/Data/Application/C3079EB8-2190-4161-A5E4-ABFFB3374393/Documents

so that is where my database is being placed.所以这就是我的数据库被放置的地方。

I'm wondering if I need to change that location and where that might be... In files I see the folders like below and I'd like to see my app in there..我想知道我是否需要更改那个位置以及它可能在哪里......在文件中,我看到如下文件夹,我想在那里看到我的应用程序..

在此处输入图片说明

Thanks to DonMag's suggestion above I wound up adding the keys he suggested to my info.plist and the file now appears in the "Files.app".感谢上面 DonMag 的建议,我最终将他建议的密钥添加到我的 info.plist 中,该文件现在出现在“Files.app”中。 The keys I added all together were:我加在一起的键是:

<key>UIFileSharingEnabled</key>
<true/>
<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>
<key>UISupportsDocumentBrowser</key>
<true/>

See ManagingYourMoney icon below:请参阅下面的ManagingYourMoney 图标:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM