1

I have created SQLite database and have copied it in the root of the project like that:

enter image description here

The database is called MobileSell.db It appears in Visual Studio like that:

enter image description here

My question is how can I reference it so afterwards I can say connection.InsertIntoTableArticles(value)(this is pseudo code)

2
  • 1
    Please refer to this Commented Jan 15, 2018 at 2:59
  • Have you solved your problem? Commented Jan 15, 2018 at 9:53

1 Answer 1

1

You can refer to this.

There only three steps to achieve it:

1) Create Assets folder which is parallel with Resources folder in your project, put your .db file into it.

2) Copy the .db file to SDCard when first open the app;

3) Use SQLite.SQLiteConnection(path) to open your .db and query it.

Sign up to request clarification or add additional context in comments.

4 Comments

Could you give more details on point 2) Copy the .db file to SDCard when first open the app?
Please use BinaryReader to read from your .db file and use BinaryWriter to write to you sdcard. In Android, you can't open .db from Assets or raw directly, so you need copy it to other folder, and this SQLite.SQLiteConnection(path) can open any folder.
Instead of copying .db to SDCard, could I copy the .db file into the apk folder of the app and then reference it from there like that: SQLite.SQLiteConnection(path-to-apk-folder)?
Yes, like /data/data/package name/test.db

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.