locked
Copy Local Sqlite .db file to another path location RRS feed

  • Question

  • User386302 posted

    Hey,

    So I am trying to copy out the local .db file so users can import it on another device and use it with the app.

    The DB file is stored here: *string dbPath= Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "moose.db"); * I tried File.Move, File.Copy but no go with that. Any suggestions?

    Monday, July 8, 2019 3:48 PM

Answers

  • User386302 posted

    Actually I discovered the actual File Path and it works with File.Copy or File.Move.

    Use : /storage/emulated/0/Download/databasename.db

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Monday, July 8, 2019 8:09 PM

All replies

  • User2148 posted

    I think you should explain better which is the result. Do you have an excetpion?

    If you have to copy the file to an External Storage you should give permission…. are them ok?

    Monday, July 8, 2019 4:48 PM
  • User386302 posted

    You are correct my apologies.

                 string src = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "moose.db");
                                string dest = ("//sdcard//Download//moose.db//");
                                File.Copy(src, dest);
    

    Says that Destination Path does not exist. All permissions are set in the manifest file.

    Monday, July 8, 2019 5:44 PM
  • User2148 posted

    You should use GetExternalFilesDir

    https://docs.microsoft.com/it-it/xamarin/android/platform/files/external-storage?tabs=windows

    Monday, July 8, 2019 6:11 PM
  • User386302 posted

    Actually I discovered the actual File Path and it works with File.Copy or File.Move.

    Use : /storage/emulated/0/Download/databasename.db

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Monday, July 8, 2019 8:09 PM