1
我必须为我的客户的iPad应用程序,现在我需要添加应用功能,他们可以点击一个按钮,将邮件程序和发送使用他们的SQLite数据库由应用程序给我的问题诊断。我跟着苹果的示例应用程序,它运行良好。我收到了附带的db文件发送的电子邮件。从电子邮件下载文件并在SQLite Manager(Firefox)中打开它之后,所有表格模式都是正确的,但是没有数据。有谁知道问题是什么?我下载的db文件与设备的大小完全一样。谢谢。SQLite数据库没有从iPad应用程序内通过电子邮件发送后数据
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:@"[email protected]"];
[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
}
非常感谢!我会尝试不同的事情来弄清楚。我稍后会回来标记你的答案。你是对的,我可能不需要支持任何低于3.0的东西,这只是一个很好的做法,我借用了苹果示例应用程序中的代码。 –
我面临同样的问题,你做完了吗?我可以将sqlite文件附加到邮件中,但我永远无法通过MAC上的LiYa应用程序打开它 – ikzjfr0