SQLite Path and Deploy

JassimRahmaJassimRahma USMember ✭✭✭✭

Hi,

I am starting to use the SQLite and would like to ask questions please..

  1. I am setting the path of the db3 here:

**Android:
**

dbPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);



**iOS:
**

var documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
dbPath = System.IO.Path.Combine(documentsPath, "..", "Library");


Is this the correct / recommended path to use?

  1. Where can I find the above path in my Droid and iOS projects> for example if the file was created and I want to make some changes in the data using external DBMS so where to locate the file? (I am using Mac).

  2. If file was created in the above path, do I need to do anything extra to include the file in the deploy process? or it will automatically include it for both iOS and Droid?

Thanks,
Jassim

Answers

  • ManojkumarMaliManojkumarMali USMember ✭✭✭

    Hi @JassimRahma,

    1- You are using right path to create database
    2- The db files will create on device, so you can not find it on pc/machine.
    3- While releasing app, you don't need to do any thing extra for database. This will be automatically handled by app.

  • JassimRahmaJassimRahma USMember ✭✭✭✭
    What if I have existing database and I want to use it?

    Because I want to create the data using my DM explorer and when it’s all ready I will include it in my project?

    How can I achieve this?
  • ManojkumarMaliManojkumarMali USMember ✭✭✭

    Sorry, I haven't done this kind of functionality till now.
    So I can't help you in it.

  • CharwakaCharwaka INMember ✭✭✭✭✭

    @JassimRahma said:
    Hi,

    I am starting to use the SQLite and would like to ask questions please..

    1. I am setting the path of the db3 here:

    **Android:
    **

    dbPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);



    **iOS:
    **

    var documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
dbPath = System.IO.Path.Combine(documentsPath, "..", "Library");


    Is this the correct / recommended path to use?

    1. Where can I find the above path in my Droid and iOS projects> for example if the file was created and I want to make some changes in the data using external DBMS so where to locate the file? (I am using Mac).

    2. If file was created in the above path, do I need to do anything extra to include the file in the deploy process? or it will automatically include it for both iOS and Droid?

    Thanks,
    Jassim

    did you followed this tutorial ?

    https://codeproject.com/Articles/1097179/SQLite-with-Xamarin-Forms-Step-by-Step-guide

  • JassimRahmaJassimRahma USMember ✭✭✭✭

    @Charwaka

    if (!File.Exists(path))
    {
        File.Copy(sqliteFilename, path);
    }
    

    gives:

    Database/ConvertAnyDatabase.cs(40,17,40,21): error CS0103: The name 'File' does not exist in the current context

    although I already have:

    using System;
    using SQLite;
    using System.Collections.Generic;
    using System.Linq;
    using System.IO;
    using Xamarin.Forms;
    
Sign In or Register to comment.