/// <summary> /// this function is used as an upgrade function too. /// </summary> /// <returns></returns> private static List <ConversationListObject> GetConversations() { List <ConversationListObject> convList = null; appSettings.TryGetValue <string>(HikeConstants.FILE_SYSTEM_VERSION, out _currentVersion); if (_currentVersion == null) { _currentVersion = "1.0.0.0"; } // this will ensure that we will show tutorials in case of app upgrade from any version to version later that 1.5.0.8 if (Utils.compareVersion(_currentVersion, "1.5.0.8") != 1) // current version is less than equal to 1.5.0.8 { WriteToIsoStorageSettings(App.SHOW_FAVORITES_TUTORIAL, true); WriteToIsoStorageSettings(App.SHOW_NUDGE_TUTORIAL, true); } if (_currentVersion == "1.0.0.0") // user is upgrading from version 1.0.0.0 to latest { /* * 1. Read from individual files. * 2. Overite old files as they are written in a wrong format */ convList = ConversationTableUtils.getAllConversations(); // this function will read according to the old logic of Version 1.0.0.0 ConversationTableUtils.saveConvObjectListIndividual(convList); WriteToIsoStorageSettings(HikeViewModel.NUMBER_OF_CONVERSATIONS, convList != null ? convList.Count : 0); // there was no country code in first version, and as first version was released in India , we are setting value to +91 WriteToIsoStorageSettings(COUNTRY_CODE_SETTING, "+91"); App.WriteToIsoStorageSettings(App.SHOW_FREE_SMS_SETTING, true); return(convList); } else if (Utils.compareVersion(_currentVersion, "1.5.0.0") != 1) // current version is less than equal to 1.5.0.0 and greater than 1.0.0.0 { /* * 1. Read from Convs File * 2. Store each conv in an individual file. */ convList = ConversationTableUtils.getAllConvs(); ConversationTableUtils.saveConvObjectListIndividual(convList); WriteToIsoStorageSettings(HikeViewModel.NUMBER_OF_CONVERSATIONS, convList != null ? convList.Count : 0); string country_code = null; App.appSettings.TryGetValue <string>(App.COUNTRY_CODE_SETTING, out country_code); if (string.IsNullOrEmpty(country_code) || country_code == "+91") { App.WriteToIsoStorageSettings(App.SHOW_FREE_SMS_SETTING, true); } else { App.WriteToIsoStorageSettings(App.SHOW_FREE_SMS_SETTING, false); } return(convList); } else // this corresponds to the latest version and is called everytime except update launch { int convs = 0; appSettings.TryGetValue <int>(HikeViewModel.NUMBER_OF_CONVERSATIONS, out convs); convList = ConversationTableUtils.getAllConvs(); int convListCount = convList == null ? 0 : convList.Count; // This shows something failed while reading from Convs , so move to backup plan i.e read from individual files if (convListCount != convs) { convList = ConversationTableUtils.GetConvsFromIndividualFiles(); } return(convList); } }