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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:45:31+00:00 2026-05-25T06:45:31+00:00

I have a Monodroid app. where I use Mono.Data.SQLite and Sytem.Data in order to

  • 0

I have a Monodroid app. where I use Mono.Data.SQLite and Sytem.Data in order to connect to an SQLite database. If I create the database programaticly it runs just fine, but if I place my database “test.db” in the Assets folder and try to copy it, I get a FileNotFoundException. Below is the code I use in order to try and copy the database and then connect to it.

 public class Activity1 : Activity
{
    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);

        TextView tv = new TextView(this);
        string dbPath = Path.Combine(
        System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal),
        "test.db");

        bool exists = File.Exists(dbPath);
        if (!exists)
            SqliteConnection.CreateFile(dbPath);
        var connection = new SqliteConnection("Data Source=" + dbPath);
        connection.Open();
        if (!exists)
        {
            Stream myInput = Assets.Open("test.db");
            String outFileName = dbPath + "test.db";
            Stream myOutput = new FileStream(outFileName, FileMode.OpenOrCreate);

            byte[] buffer = new byte[1024];
            int b = buffer.Length;
            int length;
            while ((length = myInput.Read(buffer, 0, b)) > 0)
            {
                myOutput.Write(buffer, 0, length);
            }

            myOutput.Flush();
            myOutput.Close();
            myInput.Close();
        }

        using (var contents = connection.CreateCommand())
        {
            contents.CommandText = "SELECT [Field1], [Field2] from [Table]";
            var r = contents.ExecuteReader();
            while (r.Read())
                tv.Text += string.Format("\n\tField1={0}; Field2={1}",
                        r["Field1"].ToString(), r["Field2"].ToString());
        }
        connection.Close();


        SetContentView(tv);
   }
}

}

  • 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-25T06:45:32+00:00Added an answer on May 25, 2026 at 6:45 am

    At first glance I see some possible problems here:

    1. Is the build action for the file in your Assets folder set to AndroidAsset?
    2. When the file doesn’t exist, you’re writing to dbPath + “test.db”, but dbPath already contains the file name
    3. I would recommend checking for/creating the file prior to creating and opening the connection
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to port a windows 6.5 app to both Monodroid and Monotouch. Now
I have installed MonoDroid and the hello world sample. I compile the app and
I'm trying to re-write a java android app into monodroid, however I have come
Have just started using Google Chrome , and noticed in parts of our site,
Have just started using Visual Studio Professional's built-in unit testing features, which as I
Have had to write my first proper multithreaded coded recently, and realised just how
I am creating buttons dynamically for a user-based app. Now I have to tell
I have begun evaluating MonoDroid. (I've built many apps using Android+Eclipse) I created new-from-template
I have the following test code (based on standard monodroid HelloWorld) namespace TestGREF {
My monodroid application builds and runs fine, but breakpoints are not being hit. This

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.