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

  • SEARCH
  • Home
  • 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 6873991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:08:20+00:00 2026-05-27T04:08:20+00:00

I am creating database in my app,after creating the Db,i am trying to copy

  • 0

I am creating database in my app,after creating the Db,i am trying to copy the db from the app bundle to Doc directory.But i could not copy it,i am getting error like
The operation couldn’t be completed. (Cocoa error 260.)
Below shown is the code what i am using,please help me to fix this issue

dbName="userDetails.db";
returnCode=sqlite3_open(dbName,&handler);
if(returnCode!=SQLITE_OK)
    NSLog(@"message---%s",sqlite3_errmsg(handler));
else
    NSLog(@"sucess---%d",returnCode);

NSFileManager *fmgr=[NSFileManager defaultManager];
NSError *error;
NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
NSString *path=[paths objectAtIndex:0];
NSString *docPath=[path stringByAppendingPathComponent:@"userDetails.db"];
if(![fmgr fileExistsAtPath:docPath]){
    NSString *defaultDBPath=[[[NSBundle mainBundle]resourcePath]stringByAppendingPathComponent:@"userDetails.db"];
    if(![fmgr copyItemAtPath:defaultDBPath toPath:docPath error:&error])
        NSLog(@"failure message----%@",[error localizedDescription]);
}
  • 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-05-27T04:08:21+00:00Added an answer on May 27, 2026 at 4:08 am

    Actually I am little confuse with your code. Are you trying to programmatically create a database in the app bundle and then copying it to documents directory? If this is what you are doing then you need to know that you can’t create or modify anything in app bundle. You must create this database in Documents directory. You should do something like this –

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES);
        NSString *documentsDir = [paths objectAtIndex:0];
    
        NSString * databasePath = [documentsDir stringByAppendingPathComponent:@"XYZ.sqlite"];
    
        // generate databasePath programmatically
        if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) 
        {
    
            // your  code here
        }
    

    But if you already have a database in your app (and not dynamically creating) and you just want to copy it to documents directory then you should follow @Santosh Gurram answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm creating a web app that's running on an Advantage Database server, not my
I've been trying to pull a copy of my sqlite database from my android
I'm creating a web-database driven offline web-app targeted at iOS devices. I'm trying to
I'm creating and app that will rely on a database, and I have all
I'm creating a grails app over a legacy database. There is a table out
I'm creating a dictionary app. My Sqlite database is about 15MB and on the
I am currently creating an iOS app, which connects to a database and asynchronously
When creating database tables I'm often stumped when trying to name my time/date/timestamp fields.
i am creating an app that needs a database. i created it using sqlite
In my android app I've got the below code creating my database. This works

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.