private async Task deserializeJsonAsync()
        {
            try
            {
                var jsonSerializer = new DataContractJsonSerializer(typeof(MobileNumber));
                var myStream       = await ApplicationData.Current.LocalFolder.OpenStreamForReadAsync(JSONFILENAME);

                Mnum = (MobileNumber)jsonSerializer.ReadObject(myStream);
                MessagetoUser.Text = "Your Emergency Contact number has been saved.";
                // Emergency number has been fed by user
                NumberFed      = true;
                button.Content = "Change Number";
                if (_accelerometer != null)
                {
                    SendButton.IsEnabled = true;
                    rootPage.NotifyUser("", NotifyType.StatusMessage);
                }
            }
            catch (System.Exception)
            {
                MessagetoUser.Text   = "Please enter your emergency contact number to get started!";
                SendButton.IsEnabled = false;
                NumberFed            = false;
                Mnum           = null;
                button.Content = "Enter Number";
                if (_accelerometer != null)
                {
                    rootPage.NotifyUser("Please enter your emergency contact number to get started.", NotifyType.ErrorMessage);
                }
            }
        }
        private void EnterButtonAction(MobileNumber Number)
        {
            MobileNumber num = MainPage.Current.Mnum;

            if (num == null)
            {
                if (isMobileNumberValid(Number.countryCode, Number.tenDigits))
                {
                    EnterNumberButton.IsEnabled = true;
                }
                else
                {
                    EnterNumberButton.IsEnabled = false;
                }
                return;
            }

            if (Number == null || num.countryCode != CountryCodeTextBox.Text || num.tenDigits != WelcometextBox.Text)
            {
                InvalidNumberMessageTextBlock.Text = "";
                if (Number != null && isMobileNumberValid(Number.countryCode, Number.tenDigits))
                {
                    EnterNumberButton.IsEnabled = true;
                }
                else
                {
                    EnterNumberButton.IsEnabled = false;
                }
            }
            else
            {
                InvalidNumberMessageTextBlock.Text = "The above number is your current emergency contact.";
                EnterNumberButton.IsEnabled        = false;
            }
        }
        private async Task writeJsonAsync(MobileNumber Number)
        {
            var serializer = new DataContractJsonSerializer(typeof(MobileNumber));

            using (var stream = await ApplicationData.Current.LocalFolder.OpenStreamForWriteAsync(
                       JSONFILENAME,
                       CreationCollisionOption.ReplaceExisting))
            {
                serializer.WriteObject(stream, Number);
            }
            InvalidNumberMessageTextBlock.Text = "Number Successfully Saved!";
        }
        /// <summary>
        /// Whenever this page is navigated to, the page tries to retrieve the user provided emergency contact number
        /// and display it, providing the user with an option to edit/change
        /// </summary>
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            EnterNumberButton.IsEnabled = false;
            MobileNumber Number = null;

            if (MainPage.Current.Mnum == null)
            {
                await deserializeJsonAsync(Number);
            }
            // EnterButtonAction(Number);
            else
            {
                Number = MainPage.Current.Mnum;
                CountryCodeTextBox.Text = Number.countryCode;
                WelcometextBox.Text     = Number.tenDigits;
                InvalidNumberMessageTextBlock.Foreground = new Windows.UI.Xaml.Media.SolidColorBrush(Windows.UI.Colors.Green);
                InvalidNumberMessageTextBlock.Text       = "The above number is your current emergency contact.";
            }
        }
        private async Task deserializeJsonAsync(MobileNumber Number)
        {
            try
            {
                var jsonSerializer = new DataContractJsonSerializer(typeof(MobileNumber));
                var myStream       = await ApplicationData.Current.LocalFolder.OpenStreamForReadAsync(JSONFILENAME);

                Number = (MobileNumber)jsonSerializer.ReadObject(myStream);
                CountryCodeTextBox.Text = Number.countryCode;
                WelcometextBox.Text     = Number.tenDigits;
                InvalidNumberMessageTextBlock.Foreground = new Windows.UI.Xaml.Media.SolidColorBrush(Windows.UI.Colors.Green);
                InvalidNumberMessageTextBlock.Text       = "The above number is your current emergency contact.";
            }
            catch (System.Exception)
            {
                InvalidNumberMessageTextBlock.Foreground = new Windows.UI.Xaml.Media.SolidColorBrush(Windows.UI.Colors.Red);
                InvalidNumberMessageTextBlock.Text       = "No number saved as of now.";
            }
        }
        private void WelcometextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (isMobileNumberValid(CountryCodeTextBox.Text, WelcometextBox.Text))
            {
                GreenTick.Visibility = Windows.UI.Xaml.Visibility.Visible;
                RedCross.Visibility  = Windows.UI.Xaml.Visibility.Collapsed;
            }
            else
            {
                GreenTick.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                RedCross.Visibility  = Windows.UI.Xaml.Visibility.Visible;
            }
            MobileNumber temp = new MobileNumber()
            {
                countryCode = CountryCodeTextBox.Text, tenDigits = WelcometextBox.Text
            };

            EnterButtonAction(temp);
        }
        // Enter Number Button Click
        private async void WelcomeButton_click(object sender, RoutedEventArgs e)
        {
            // Check the validity of the formt of the number entered by the user, and pass it as an object to SendTexyMessage Page.
            bool error = false;
            // Getting the number entered by the user
            string mNumber = WelcometextBox.Text;
            // Getting Country Code
            string cCode = CountryCodeTextBox.Text;
            // Appending to get user's full number
            string userNumber = cCode + mNumber;

            error = !isMobileNumberValid(cCode, mNumber);

            // Erroneous Number entered by user
            if (error)
            {
                InvalidNumberMessageTextBlock.Text = "You have not entered a valid mobile number! Please check and try again!";
            }
            // Else the entered number has a valid format, serialize it.
            else
            {
                MobileNumber Number = new MobileNumber()
                {
                    countryCode = cCode,
                    tenDigits   = mNumber
                };

                MainPage.Current.Mnum      = Number;
                MainPage.Current.NumberFed = true;

                // Serialising the entered number
                await writeJsonAsync(Number);

                // Number saved, now moving back to MainPage
                Frame.Navigate(typeof(MainPage), "Disable");
            }
        }