[Uwp Little White Diary-1] determine if the app is the first time you run the Initialize SQLite database

Source: Internet
Author: User

Use application settings to implement this functionality.

1. First, get the container for app settings:

Applicationdatacontainer localsettings = ApplicationData.Current.LocalSettings;

Because the key is not assigned to Fireststart when the container is fetched, the following is a direct judge of whether it is NULL, or NULL is the first time the app is run,

Then in else the key is assigned to Fireststart, then the else code can only be executed once. Of course later on the UI can add a Switchbutton to control what, that is to open the brain hole.

1   /// <summary>2         ///Page Loading Tags3         /// </summary>4         /// <param name= "Sender" ></param>5         /// <param name= "E" ></param>6         Private voidPage_loaded (Objectsender, RoutedEventArgs e)7         {8             //interpret if the app is the first to start, and if so, initialize the app's database9             Ten             if(localsettings.values["Firststart"] !=NULL) One             { A                 //fills the text of Datetextblock and Timetextboloc -DateTime now =DateTime.Now; -Datetextblock.text = Now. ToString ("YYYY-MM-DD"); theTimetextblock.text = Now. ToString ("HH:mm:ss"); -  -                 //populating the GridView - mark. Clear (); +Mark =Sqlitehelper.readdata (Mark); -             } +             Else A             { at Firststart (); -localsettings.values["Firststart"] =true; -  -                 //fills the text of Datetextblock and Timetextboloc -DateTime now =DateTime.Now; -Datetextblock.text = Now. ToString ("YYYY-MM-DD"); inTimetextblock.text = Now. ToString ("HH:mm:ss"); -  to                 //populating the GridView + mark. Clear (); -Mark =Sqlitehelper.readdata (Mark); the             } *              $                Panax Notoginseng}

[UWP Little White Diary-1] determine if the app is the first to run the Initialize SQLite database

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.