diff --git a/app/src/main/java/net/mynero/wallet/fragment/dialog/NodeSelectionBottomSheetDialog.java b/app/src/main/java/net/mynero/wallet/fragment/dialog/NodeSelectionBottomSheetDialog.java index c8f8f39..eee0573 100644 --- a/app/src/main/java/net/mynero/wallet/fragment/dialog/NodeSelectionBottomSheetDialog.java +++ b/app/src/main/java/net/mynero/wallet/fragment/dialog/NodeSelectionBottomSheetDialog.java @@ -73,6 +73,7 @@ public class NodeSelectionBottomSheetDialog extends BottomSheetDialogFragment im } } } catch (JSONException e) { + // if stored node is old string format, try parse and upgrade, if fail then remove try { String nodeString = jsonArray.getString(i); Node node = Node.fromString(nodeString); diff --git a/app/src/main/java/net/mynero/wallet/service/PrefService.java b/app/src/main/java/net/mynero/wallet/service/PrefService.java index d19ebd2..bea2a25 100644 --- a/app/src/main/java/net/mynero/wallet/service/PrefService.java +++ b/app/src/main/java/net/mynero/wallet/service/PrefService.java @@ -45,12 +45,17 @@ public class PrefService extends ServiceBase { JSONObject nodeJson = new JSONObject(nodeString); return Node.fromJson(nodeJson); } catch (JSONException e) { - if(!nodeString.isEmpty()) { - Node node = Node.fromString(nodeString); - if(node != null) { - edit().putString(Constants.PREF_NODE_2, node.toJson().toString()).apply(); - return node; - } + // stored node is not json format, upgrade if possible + return upgradeOldNode(nodeString); + } + } + + private Node upgradeOldNode(String nodeString) { + if(!nodeString.isEmpty()) { + Node node = Node.fromString(nodeString); + if(node != null) { + edit().putString(Constants.PREF_NODE_2, node.toJson().toString()).apply(); + return node; } } return null;