locked
How to create a BackUp or make a copy of SQLite DB RRS feed

  • Question

  • Understand that If user Uninstall WinRT App, the SQLite Database in it will be erased or gone. So, it is possible to make a copy of the Database and How to do it?

    1) Can make a copy and  Upload it to SkyDrive ?

    2) Since Tablet has USB slot, can make a copy to the USB-Thumb Drive?

    Your help on this is much appreciated. Thanks

    Monday, September 16, 2013 7:29 AM

Answers

  • Hi FireDance,

    1, Yes you can, as Zakkar said, you cold copy the sqlite db to another place of the computer, but since the store app runs in a sandbox, you can only copy the file to the following place:

    Local app data, Roaming app data, Temporary app data, App installed location, Downloads folder, Documents library, Music library, Pictures library, Videos library, Removable devices, Home group, Media Server devices.

    And the best practice is you ask the user to choose where they want to save the copy of the DB by FileSavePicker

    2, Yes, USB is a kind of removable Device, you could copy into it by specify Removable Storage capability in the app’s manifest.  Take a look this toturial: Accessing content on removable storage, and furthermore I will suggest you a sample from MSDN code: Removable storage sample (Windows 8.1) .

    Best Regards,

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.





    Thursday, September 19, 2013 1:23 AM
    Moderator
  • Hi ,

    In Addition to hez and in case you don't like to use the default folders, you can also create your own folder , put it in your future access list and then copy in there the db.

    For example.

      private StorageFolder m_downloadfolder;

     public StorageFolder Download_Folder
            {
                get { return m_downloadfolder; }
                set { m_downloadfolder = value; }
            }

     if (StorageApplicationPermissions.FutureAccessList.Entries.Any(item => item.Metadata == "myfolder"))
                    {
                        // if we have the folder in the FutureAccessList, just ui
                        var entry = StorageApplicationPermissions.FutureAccessList.Entries.FirstOrDefault(item => item.Metadata == "myfolder");
                        Download_Folder = await StorageApplicationPermissions.FutureAccessList.GetFolderAsync(entry.Token);
                    }
                    else
                    {
                        Download_Folder = await DownloadsFolder.CreateFolderAsync("myfolder");
                        StorageApplicationPermissions.FutureAccessList.Add(Download_Folder, "myfolder");
                    }

    Now you have your own downloadfolder .


    • Edited by zakkar Thursday, September 19, 2013 6:21 AM
    • Marked as answer by Jamles HezModerator Monday, September 23, 2013 3:27 AM
    Thursday, September 19, 2013 6:20 AM

All replies

  • Hi ,

    When you create the database , you are creating it in a folder with a name. Correct ?

    Why don't you create a button somewhere in your application  ,which will take the db file as a copy , paste it in a folder of your own and then upload in your skydrive ?

    For example 

       this.dbpath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "mydatabase.db");

       StorageFile myFile = await storageFolder.GetFileAsync("mydatabase.db");

    Monday, September 16, 2013 10:31 AM
  • Hi FireDance,

    1, Yes you can, as Zakkar said, you cold copy the sqlite db to another place of the computer, but since the store app runs in a sandbox, you can only copy the file to the following place:

    Local app data, Roaming app data, Temporary app data, App installed location, Downloads folder, Documents library, Music library, Pictures library, Videos library, Removable devices, Home group, Media Server devices.

    And the best practice is you ask the user to choose where they want to save the copy of the DB by FileSavePicker

    2, Yes, USB is a kind of removable Device, you could copy into it by specify Removable Storage capability in the app’s manifest.  Take a look this toturial: Accessing content on removable storage, and furthermore I will suggest you a sample from MSDN code: Removable storage sample (Windows 8.1) .

    Best Regards,

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.





    Thursday, September 19, 2013 1:23 AM
    Moderator
  • Hi ,

    In Addition to hez and in case you don't like to use the default folders, you can also create your own folder , put it in your future access list and then copy in there the db.

    For example.

      private StorageFolder m_downloadfolder;

     public StorageFolder Download_Folder
            {
                get { return m_downloadfolder; }
                set { m_downloadfolder = value; }
            }

     if (StorageApplicationPermissions.FutureAccessList.Entries.Any(item => item.Metadata == "myfolder"))
                    {
                        // if we have the folder in the FutureAccessList, just ui
                        var entry = StorageApplicationPermissions.FutureAccessList.Entries.FirstOrDefault(item => item.Metadata == "myfolder");
                        Download_Folder = await StorageApplicationPermissions.FutureAccessList.GetFolderAsync(entry.Token);
                    }
                    else
                    {
                        Download_Folder = await DownloadsFolder.CreateFolderAsync("myfolder");
                        StorageApplicationPermissions.FutureAccessList.Add(Download_Folder, "myfolder");
                    }

    Now you have your own downloadfolder .


    • Edited by zakkar Thursday, September 19, 2013 6:21 AM
    • Marked as answer by Jamles HezModerator Monday, September 23, 2013 3:27 AM
    Thursday, September 19, 2013 6:20 AM