我有一个 iPad 应用程序供我的客户使用,现在我需要在应用程序中添加一个功能,他们可以单击一个按钮来打开电子邮件程序并将应用程序使用的 sqlite 数据库发送给我以进行问题诊断。我遵循了苹果的示例应用程序,它运行良好。我收到了附有数据库文件的电子邮件。从电子邮件下载文件并在 SQLite Manager(Firefox) 中打开它后,所有表模式都是正确的,但是没有数据。有谁知道问题是什么?我下载的 db 文件与从设备下载的文件大小完全相同。谢谢。
Class mailClass = (NSClassFromString(@"MFMailComposeViewController"));
if (mailClass != nil)
{
// check whether the current device is configured for sending emails
if ([mailClass canSendMail])
{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:@"database file from ios app"];
// Set up recipients
NSArray *toRecipients = [NSArray arrayWithObject:@"someEmailAddress@gmail.com"];
[picker setToRecipients:toRecipients];
// Attach db file to the email
NSString *path = [[NSBundle mainBundle] pathForResource:@"MyDB" ofType:@"sqlite"];
NSData *myData = [NSData dataWithContentsOfFile:path];
[picker addAttachmentData:myData mimeType:@"application/x-sqlite3" fileName:@"MyDB.sqlite"];
// Fill out the email body text
NSString *emailBody = @"test email with db";
[picker setMessageBody:emailBody isHTML:NO];
picker.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:picker animated:YES];
[picker release];
}
else // email not configured
{
// Alert email is not configured
}
}
else // older iOS
{
// Alert OS is too old
}