locked
how to copy sqlite database from assets to localfolder

    Question

  • hi there i want to publish my app it runs fine in visual studio(debug mode) it also copy database from assets to local drive.but when i publish it for release(x86).

    it build successful but not coping database to local folder.. please help i am using this code

    \

     public static async void CopyFileAssetsToLocalFolder(string FilePathToCopy)
            {
                //get the storage for your app
                Windows.Storage.StorageFolder store = Windows.Storage.ApplicationData.Current.LocalFolder;
                StorageFile prayerFile = null;
                try
                {
                    prayerFile = await store.GetFileAsync(FilePathToCopy);
                }
                catch (System.IO.FileNotFoundException)
                { }
    
                if (prayerFile == null)
                {
                    //get the file from Assets
    
                    StorageFolder install = Windows.ApplicationModel.Package.Current.InstalledLocation;
                    StorageFile installFile = await install.GetFileAsync(FilePathToCopy);
    
                    await installFile.CopyAsync(store);
                }
            }

    Wednesday, March 12, 2014 9:12 AM

All replies

  • is there any buddy who can reply for the same..............

    i just want to know how to copy database from assets folder to local folder..my code is working fine in visual studio but when i made app package database with 0kb only with no table copied in local folder
    • Edited by ankit15 Thursday, March 13, 2014 12:43 PM
    Thursday, March 13, 2014 12:41 PM
  • Hi ankit15,

    Have you tried to set your file as "Copy Always"?

    --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.

    Wednesday, March 19, 2014 6:05 AM
    Moderator
  • ya i already  apply this but and my database is in appx but when i run it with powersell only 0 kb database without any table is created.
    Wednesday, March 19, 2014 7:34 AM
  • Hi ankit15,

    Could you validate if the SQLite database in your package is a not empty one? Copy database to local is as copy image to local, should not lost any data.

    --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, March 20, 2014 8:06 AM
    Moderator