Link sqlite3 db with iPhone app

I am trying to link a SQLite3 database file with our application so that it is easy to open a database backup from email. The following, however, does not seem to work, since Mail still does not recognize the file (on iPad and iPhone 4):

<key>UTExportedTypeDeclarations</key> <array> <dict> <key>UTTypeConformsTo</key> <array> <string>public.database</string> <string>public.data</string> </array> <key>UTTypeDescription</key> <string>App Database File</string> <key>UTTypeIdentifier</key> <string>com.company.App.db</string> <key>UTTypeTagSpecification</key> <dict> <key>public.filename-extension</key> <string>db</string> <key>public.mime-type</key> <string>application/x-sqlite3</string> </dict> </dict> </array> <key>CFBundleDocumentTypes</key> <dict> <key>CFBundleTypeName</key> <string>App Database</string> <key>CFBundleTypeIconFiles</key> <array> <string>Icon-Small.png</string> <string>Icon.png</string> </array> <key>CFBundleTypeRole</key> <string>Editor</string> <key>LSItemContentTypes</key> <array> <string>com.company.App.db</string> </array> <key>LSHandlerRank</key> <string>Alternate</string> </dict> </dict> 

Any idea what I'm doing wrong?

0
iphone sdk ipad
Jun 27 '10 at 12:42 on
source share
3 answers

Ok, I made it out. If you use the target info panel instead and add your document type there (and then select SQLite as the type), it just works. Obviously, you exported the type as described above.

0
Jun 27 2018-10-12T00:
source share

For completeness and possibly my own reference, here are some details later that made me work for me:

Declaring document types supported by your application (e.g. sqlite3 database)

 <key>UTExportedTypeDeclarations</key> <array> <dict> <key>UTTypeIdentifier</key> <string>com.company.sqlite3.database</string> <key>UTTypeReferenceURL</key> <string>http://www.company.com/</string> <key>UTTypeDescription</key> <string>MyCompany SQLite Database</string> <key>UTTypeIconFile</key> <array> <string>Icon-Small.png</string> <string>Icon.png</string> </array> <key>UTTypeConformsTo</key> <array> <string>public.database</string> <string>public.data</string> </array> <key>UTTypeTagSpecification</key> <dict> <key>public.filename-extension</key> <array> <string>sqlite</string> </array> <key>public.mime-type</key> <array> <string>application/x-sqlite3</string> <string>application/octet-stream</string> </array> </dict> </dict> </array> <key>CFBundleDocumentTypes</key> <array> <dict> <key>CFBundleTypeName</key> <string>MyCompany SQLite Database</string> <key>CFBundleTypeIconFiles</key> <array> <string>Icon-Small.png</string> <string>Icon.png</string> </array> <key>CFBundleTypeExtensions</key> <array> <string>sqlite</string> </array> <key>CFBundleTypeMIMETypes</key> <array> <string>application/x-sqlite3</string> <string>application/octet-stream</string> </array> <key>LSHandlerRank</key> <string>Alternate</string> <key>LSItemContentTypes</key> <array> <string>com.company.sqlite3.database</string> </array> <key>NSPersistentStoreTypeKey</key> <string>SQLite</string> </dict> </array> 

Copy the above XML into your Info.plist file.

Setting the Store Type type to SQLite was not a problem for me for the killer.

My previous post mentioned a rather incorrect way to make it work, which accepts all files and did not export this type correctly.

Also, if your application sends these files as attachments, make sure that it matches the MIME type that you set to capture it. The flow of applications / octets is not important, as older versions of our application email databases with this MIME type.

eg,

 [controller addAttachmentData:[NSData dataWithContentsOfFile:dbPath] mimeType:@"application/x-sqlite3" fileName:filename]; 

I'm sure someone else who is trying to find out how to get their application to support opening sqlite3 database backups finds this useful.

+5
Jul 04 '11 at 4:18
source share

According to Apple Documentation , CFBundleDocumentTypes is an array, not a dict.

You have:

 <key>CFBundleDocumentTypes</key> <dict> 

therefore, <dict> must be in the <array> element, for example:

 <key>CFBundleDocumentTypes</key> <array> <dict> <key>CFBundleTypeName</key> <string>App Database</string> <!-- ... --> </dict> </array> 
0
Jun 13 '11 at 20:33
source share



All Articles