locked
[UWP]Database Connection in Windows Store App RRS feed

  • Question

  • Hi,

    I am working on Universal Application and I want to keep the application secure as possible. So there will be encrypted database and every time I will access it will decrypt the database and then give access. So should I put the connection in App.cs and access it from all the pages or should I connect to database each time I add or modify records?


    xSHERU


    • Edited by Krunal Parekh Monday, February 15, 2016 5:32 AM subject
    Sunday, February 14, 2016 2:15 PM

Answers

  • Hello xSheru,

    It really does depends on your requirements. but I would recommend to open and close connection only when needed.

    Please see this similar example?

    https://github.com/XamlBrewer/UWP-SQLite-Sample/tree/master/XamlBrewer.Uwp.SqLiteSample

    With Regards,

    Krunal Parekh 


    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.

    • Proposed as answer by Krunal Parekh Thursday, February 25, 2016 2:19 AM
    • Marked as answer by Krunal Parekh Wednesday, March 2, 2016 9:47 AM
    Monday, February 15, 2016 5:43 AM

All replies

  • Consider what happens when your app crashes; a) what will be the state of your decrypted database b) will a memory dump expose your secret data?


    http://pauliom.wordpress.com

    Sunday, February 14, 2016 2:41 PM
  • I am keeping this scenarios in mind and opening and closing the connection as I add or modify the records and taking precautions if app crashes but because of this CPU use is increasing maybe affecting battery too. What could be best optimum solution which I can use to keep the data secure as well as reducing CPU use?

    xSHERU

    Sunday, February 14, 2016 2:46 PM
  • Hi

    Whats your data base Its a local sqlite or MS sqlserver?

    Singleton Design Patter:

    If you want a single open connection for entire of your app and be accessible from any where in you app use Singleton design Pattern

    don't need to encrypt whole data base file, just encrypt sensitive data field and Decrypt them whenever you retrieve them.

    You can use EntityFramework library for better resault. 

    Sunday, February 14, 2016 2:56 PM
  • I am using SQLite Database

    xSHERU

    Sunday, February 14, 2016 3:00 PM
  • Hello xSheru,

    It really does depends on your requirements. but I would recommend to open and close connection only when needed.

    Please see this similar example?

    https://github.com/XamlBrewer/UWP-SQLite-Sample/tree/master/XamlBrewer.Uwp.SqLiteSample

    With Regards,

    Krunal Parekh 


    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.

    • Proposed as answer by Krunal Parekh Thursday, February 25, 2016 2:19 AM
    • Marked as answer by Krunal Parekh Wednesday, March 2, 2016 9:47 AM
    Monday, February 15, 2016 5:43 AM