SpecialFolder.Personal existing sqlite database2019 Community Moderator ElectionHow to list the tables in a SQLite database file that was opened with ATTACH?Ship an application with a databaseHow do I check in SQLite whether a table exists?'Must Override a Superclass Method' Errors after importing a project into EclipseImprove INSERT-per-second performance of SQLite?Is quitting an application frowned upon?What are the best practices for SQLite on Android?How to use an existing database with an Android applicationAndroid Studio: Add jar as library?“cannot resolve symbol R” in Android Studio

Have the tides ever turned twice on any open problem?

Violin - Can double stops be played when the strings are not next to each other?

This word with a lot of past tenses

My adviser wants to be the first author

What is the adequate fee for a reveal operation?

Examples of transfinite towers

Do the common programs (for example: "ls", "cat") in Linux and BSD come from the same source code?

combinatorics floor summation

Does this sum go infinity?

Print a physical multiplication table

What's the meaning of a knight fighting a snail in medieval book illustrations?

Is it normal that my co-workers at a fitness company criticize my food choices?

Adventure Game (text based) in C++

What did “the good wine” (τὸν καλὸν οἶνον) mean in John 2:10?

Official degrees of earth’s rotation per day

Why does a Star of David appear at a rally with Francisco Franco?

ERC721: How to get the owned tokens of an address

Is it insecure to send a password in a `curl` command?

Most cost effective thermostat setting: consistent temperature vs. lowest temperature possible

How to explain that I do not want to visit a country due to personal safety concern?

How should I state my peer review experience in the CV?

Custom alignment for GeoMarkers

Can I use USB data pins as power source

How to write cleanly even if my character uses expletive language?



SpecialFolder.Personal existing sqlite database



2019 Community Moderator ElectionHow to list the tables in a SQLite database file that was opened with ATTACH?Ship an application with a databaseHow do I check in SQLite whether a table exists?'Must Override a Superclass Method' Errors after importing a project into EclipseImprove INSERT-per-second performance of SQLite?Is quitting an application frowned upon?What are the best practices for SQLite on Android?How to use an existing database with an Android applicationAndroid Studio: Add jar as library?“cannot resolve symbol R” in Android Studio










0















On my Xamarin android application i create db path using the "System.Environment.SpecialFolder.Personal".
I have an existing sqlite database. Where in the project and with what properties must i include the database to be used in the peronal folder?










share|improve this question






















  • You will need to include the existing DB in your project as an Asset, and then at startup copy it to the Personal folder.

    – Jason
    Mar 6 at 20:46











  • Thank you. How can i copy to the personal folder at startup. Sorry but i'm new to xamarin.

    – Charalampos Vracopoulos
    Mar 6 at 20:48











  • robgibbens.com/…

    – Jason
    Mar 6 at 20:53















0















On my Xamarin android application i create db path using the "System.Environment.SpecialFolder.Personal".
I have an existing sqlite database. Where in the project and with what properties must i include the database to be used in the peronal folder?










share|improve this question






















  • You will need to include the existing DB in your project as an Asset, and then at startup copy it to the Personal folder.

    – Jason
    Mar 6 at 20:46











  • Thank you. How can i copy to the personal folder at startup. Sorry but i'm new to xamarin.

    – Charalampos Vracopoulos
    Mar 6 at 20:48











  • robgibbens.com/…

    – Jason
    Mar 6 at 20:53













0












0








0








On my Xamarin android application i create db path using the "System.Environment.SpecialFolder.Personal".
I have an existing sqlite database. Where in the project and with what properties must i include the database to be used in the peronal folder?










share|improve this question














On my Xamarin android application i create db path using the "System.Environment.SpecialFolder.Personal".
I have an existing sqlite database. Where in the project and with what properties must i include the database to be used in the peronal folder?







c# android sqlite xamarin






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 6 at 20:45









Charalampos VracopoulosCharalampos Vracopoulos

12




12












  • You will need to include the existing DB in your project as an Asset, and then at startup copy it to the Personal folder.

    – Jason
    Mar 6 at 20:46











  • Thank you. How can i copy to the personal folder at startup. Sorry but i'm new to xamarin.

    – Charalampos Vracopoulos
    Mar 6 at 20:48











  • robgibbens.com/…

    – Jason
    Mar 6 at 20:53

















  • You will need to include the existing DB in your project as an Asset, and then at startup copy it to the Personal folder.

    – Jason
    Mar 6 at 20:46











  • Thank you. How can i copy to the personal folder at startup. Sorry but i'm new to xamarin.

    – Charalampos Vracopoulos
    Mar 6 at 20:48











  • robgibbens.com/…

    – Jason
    Mar 6 at 20:53
















You will need to include the existing DB in your project as an Asset, and then at startup copy it to the Personal folder.

– Jason
Mar 6 at 20:46





You will need to include the existing DB in your project as an Asset, and then at startup copy it to the Personal folder.

– Jason
Mar 6 at 20:46













Thank you. How can i copy to the personal folder at startup. Sorry but i'm new to xamarin.

– Charalampos Vracopoulos
Mar 6 at 20:48





Thank you. How can i copy to the personal folder at startup. Sorry but i'm new to xamarin.

– Charalampos Vracopoulos
Mar 6 at 20:48













robgibbens.com/…

– Jason
Mar 6 at 20:53





robgibbens.com/…

– Jason
Mar 6 at 20:53












1 Answer
1






active

oldest

votes


















-1














You can use Xamarin.Essentials to access your read-only bundle/asset resource and copy it without have to use native platform code or if you are coding within an Xamarin.Android project, you can directly use Android.Content's Assets



So assuming you have a database in your Android Assets folder:



Assets
db.sqlite


Xamarin Essentials / NetStd2.0 Code Example:



var copyToLocationPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "db.sqlite");
if (!File.Exists(copyToLocationPath))

using (var assetStream = await Xamarin.Essentials.FileSystem.OpenAppPackageFileAsync("db.sqlite"))
using (var fileStream = new FileStream(copyToLocationPath, FileMode.Create, FileAccess.Write))

await assetStream.CopyToAsync(fileStream);


var connection = new SqliteConnection(copyToLocationPath);


Xamarin Android code sample (Directly use Assets):



var copyToLocationPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "db.sqlite");
if (!File.Exists(copyToLocationPath))

using (var assetStream = Assets.Open("db.sqlite"))
using (var fileStream = new FileStream(copyToLocationPath, FileMode.Create, FileAccess.Write))

await assetStream.CopyToAsync(fileStream);







share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55031866%2fspecialfolder-personal-existing-sqlite-database%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    -1














    You can use Xamarin.Essentials to access your read-only bundle/asset resource and copy it without have to use native platform code or if you are coding within an Xamarin.Android project, you can directly use Android.Content's Assets



    So assuming you have a database in your Android Assets folder:



    Assets
    db.sqlite


    Xamarin Essentials / NetStd2.0 Code Example:



    var copyToLocationPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "db.sqlite");
    if (!File.Exists(copyToLocationPath))

    using (var assetStream = await Xamarin.Essentials.FileSystem.OpenAppPackageFileAsync("db.sqlite"))
    using (var fileStream = new FileStream(copyToLocationPath, FileMode.Create, FileAccess.Write))

    await assetStream.CopyToAsync(fileStream);


    var connection = new SqliteConnection(copyToLocationPath);


    Xamarin Android code sample (Directly use Assets):



    var copyToLocationPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "db.sqlite");
    if (!File.Exists(copyToLocationPath))

    using (var assetStream = Assets.Open("db.sqlite"))
    using (var fileStream = new FileStream(copyToLocationPath, FileMode.Create, FileAccess.Write))

    await assetStream.CopyToAsync(fileStream);







    share|improve this answer





























      -1














      You can use Xamarin.Essentials to access your read-only bundle/asset resource and copy it without have to use native platform code or if you are coding within an Xamarin.Android project, you can directly use Android.Content's Assets



      So assuming you have a database in your Android Assets folder:



      Assets
      db.sqlite


      Xamarin Essentials / NetStd2.0 Code Example:



      var copyToLocationPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "db.sqlite");
      if (!File.Exists(copyToLocationPath))

      using (var assetStream = await Xamarin.Essentials.FileSystem.OpenAppPackageFileAsync("db.sqlite"))
      using (var fileStream = new FileStream(copyToLocationPath, FileMode.Create, FileAccess.Write))

      await assetStream.CopyToAsync(fileStream);


      var connection = new SqliteConnection(copyToLocationPath);


      Xamarin Android code sample (Directly use Assets):



      var copyToLocationPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "db.sqlite");
      if (!File.Exists(copyToLocationPath))

      using (var assetStream = Assets.Open("db.sqlite"))
      using (var fileStream = new FileStream(copyToLocationPath, FileMode.Create, FileAccess.Write))

      await assetStream.CopyToAsync(fileStream);







      share|improve this answer



























        -1












        -1








        -1







        You can use Xamarin.Essentials to access your read-only bundle/asset resource and copy it without have to use native platform code or if you are coding within an Xamarin.Android project, you can directly use Android.Content's Assets



        So assuming you have a database in your Android Assets folder:



        Assets
        db.sqlite


        Xamarin Essentials / NetStd2.0 Code Example:



        var copyToLocationPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "db.sqlite");
        if (!File.Exists(copyToLocationPath))

        using (var assetStream = await Xamarin.Essentials.FileSystem.OpenAppPackageFileAsync("db.sqlite"))
        using (var fileStream = new FileStream(copyToLocationPath, FileMode.Create, FileAccess.Write))

        await assetStream.CopyToAsync(fileStream);


        var connection = new SqliteConnection(copyToLocationPath);


        Xamarin Android code sample (Directly use Assets):



        var copyToLocationPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "db.sqlite");
        if (!File.Exists(copyToLocationPath))

        using (var assetStream = Assets.Open("db.sqlite"))
        using (var fileStream = new FileStream(copyToLocationPath, FileMode.Create, FileAccess.Write))

        await assetStream.CopyToAsync(fileStream);







        share|improve this answer















        You can use Xamarin.Essentials to access your read-only bundle/asset resource and copy it without have to use native platform code or if you are coding within an Xamarin.Android project, you can directly use Android.Content's Assets



        So assuming you have a database in your Android Assets folder:



        Assets
        db.sqlite


        Xamarin Essentials / NetStd2.0 Code Example:



        var copyToLocationPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "db.sqlite");
        if (!File.Exists(copyToLocationPath))

        using (var assetStream = await Xamarin.Essentials.FileSystem.OpenAppPackageFileAsync("db.sqlite"))
        using (var fileStream = new FileStream(copyToLocationPath, FileMode.Create, FileAccess.Write))

        await assetStream.CopyToAsync(fileStream);


        var connection = new SqliteConnection(copyToLocationPath);


        Xamarin Android code sample (Directly use Assets):



        var copyToLocationPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "db.sqlite");
        if (!File.Exists(copyToLocationPath))

        using (var assetStream = Assets.Open("db.sqlite"))
        using (var fileStream = new FileStream(copyToLocationPath, FileMode.Create, FileAccess.Write))

        await assetStream.CopyToAsync(fileStream);








        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 6 at 21:05

























        answered Mar 6 at 20:59









        SushiHangoverSushiHangover

        53.5k54293




        53.5k54293





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55031866%2fspecialfolder-personal-existing-sqlite-database%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            1928 у кіно

            Захаров Федір Захарович

            Ель Греко