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 6833871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:02:11+00:00 2026-05-26T23:02:11+00:00

I am developing a iPhone app using Monotouch. I need to access a Sqlite

  • 0

I am developing a iPhone app using Monotouch. I need to access a Sqlite DB. In my soultion, I have a contracts, data access, business access and UI project. I have two questions:

  1. Where should I keep my DB file? Originally, I put it in the data access project. When I compile my business access project it copies the DB file to the output, but when I compile my UI project it does not (UI has a reference to business access which has a ref to data access). I moved it to the UI project, but it feels wrong to keep it there.

  2. Where should I keep the connection string to the DB? Is there a concept of config files?

  • 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-26T23:02:12+00:00Added an answer on May 26, 2026 at 11:02 pm

    Here is what we do:

    We ship a copy of the DB in the application. It is included as Content, Always Copy in the project.

    On the user’s machine, it is stored in the special directory Environment.SpecialFolder.Personal.

    When the app is started, we check to see if the database exists on the user’s system and, if not, copy it there.

    The connection string is just "Data Source=" + sDatabasePath.

    Here is a sample of the code that we use for this (I hacked in the connection stuff since we use a homebuilt class for managing the DB, but you should get the idea):

    const string DATABASE_FILE_NAME = "MyDB.db3";
    bool fSuccess = false;
    DbConnection conn = new DbConnection ();
    
    string sApplicationDir = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), "MyApplicationSubDir");
    if (!Directory.Exists (sApplicationDir)) {
        Directory.CreateDirectory (sApplicationDir);
    }
    
    // Generate the directory to the database file
    string sDatabaseDir = Path.Combine (sApplicationDir, "Database");
    m_sDatabaseDir = sDatabaseDir;
    
    if (!Directory.Exists (sDatabaseDir)) {
        Directory.CreateDirectory (sDatabaseDir);
    }
    
    // Generate the path to the database file
    string sDatabasePath = Path.Combine (sDatabaseDir, DATABASE_FILE_NAME);
    m_sDatabaseFile = sDatabasePath;
    
    // If the file does not not exist
    if (!File.Exists (sDatabasePath)) {
        // Copy the base implementation
        File.Copy (Path.Combine (Path.Combine (Environment.CurrentDirectory, "Database"), DATABASE_FILE_NAME), sDatabasePath);
    }
    
    // Initialize the DB
    conn.ConnectionString = "Data Source=" + sDatabasePath;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing an iPhone-application using monotouch. In this app, the user is supposed to
I am developing an iPhone app using Core Data and ahev noticed that I
im developing an iphone app using yahoo weather service ( i have a key
Am looking into developing an iPhone native app using Titanium Developer Since this is
I've been developing my first iPhone app part-time and would like to start using
I'm developing an iPhone app that uses the built-in SQLite database. I'm trying to
I'm developing an iPhone app and have a question about memory management. Let's say
I am developing native iPhone app. I have one requirement that, there are 5
I am developing an iPhone app using cocos2d and box2d.In this app i require
I am developing an iPhone app and are using xCode to do Build and

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.