The following forum(s) have migrated to Microsoft Q&A (Preview): Developing Universal Windows apps!
Visit Microsoft Q&A (Preview) to post new questions.

Learn More

Copy a file when App is closed RRS feed

  • Question

  • I developed a UWP app that uses a SqLite database in AppData/../LocalState. What is missing so far is an automatic backup of the database file to a user-defined storage location.

    I would like to do the backup when the app terminates to avoid excessive copying while the app is being used. I have read a lot about a Suspend handler and a possible BackgroundTask to do this but I am still not sure what the best solution would be. Can someone shed some light on this? Is it possible to have such a background tasks that also would cope with errors like: the storage location is a USB disk but it is not available. I think a background task can issue Toasts to alert the user, but can it really interact with the user?

    Wednesday, April 18, 2018 9:19 AM

All replies

  • Hello, 

    Please read the sticky posts, especially the Guide to posting: subject line tags, and don't forget add tag to your question.

    The suspension handler is not a best place because it has restriction for execution time. The out of process background task is the best choice. And you can interact with user buy toast notifications.

    Make the community better together

    Wednesday, April 18, 2018 1:53 PM