Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8595105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:21:27+00:00 2026-06-12T00:21:27+00:00

In my current app I am adding a data backup and restore feature. User

  • 0

In my current app I am adding a data backup and restore feature.
User can create back up of database and can email it.
In restore feature user can import the database from email and can replace the current.

I am able to do create back up and restore of database file.
In restore I am just copying the file from my email to app Documents file replacing current one.
The problem is that in my code for backup of database, sqlite database is converted to NSData. I don’t want to to be converted and need the exact sqlite file to be emailed.

Here is the code that I currently use to email sqlite database

-(void)backUpData
{

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];

NSString *txtPath = [documentsDirectory stringByAppendingPathComponent:@"/DemoApp.sqlite"];

NSURL *newUrl = [[NSURL alloc] initWithString:
[txtPath stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]];

NSData *sqliteData = [[NSData alloc] initWithContentsOfURL:newUrl];

//send sqliteData to email composer delegate to attach it as attachment
[self showPicker:sqliteData];

}

How I can email sqlite db without converting it to NSData?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T00:21:28+00:00Added an answer on June 12, 2026 at 12:21 am

    Use dataWithContentsOfFile when creating the NSData object giving the path rather than a url. For example:

    NSString *dbPath = [[NSBundle mainBundle] pathForResource:@"Pubs" ofType:@"db"];
    NSData   *myData = [NSData dataWithContentsOfFile:dbPath];
    
    
    [mailComposeVC addAttachmentData:myData mimeType:@"application/x-sqlite3" fileName:@"Pubs.db"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I display the time in the current app locale using Calendar? For
I'm writing a 'load' feature for my current iPhone app. Practically what I want
I have a little logging app (written in wxPython) that receives data from a
I have built in some Core Data support into my app from the Core
I'm trying to create an app in Visual Basic that will allow a user
I am trying to seed some data using custom database initializers, but can't get
Our current app runs in a single JVM. We are now splitting up the
For my current app I'm using the NSKeyedArchiver approach to persist my objects to
The design of the current app I'm working on calls for a WCF Service,
Any reliable elegant way of detecting whether the current app is a win or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.