package Ġcom . f red rik bo gg . weather app . utils Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroid . content . SharedPreferences Ċ import Ġcom . f red rik bo gg . weather app . models . Selected Location Ċ import Ġcom . google . gson . Gson Ċ Ċ object ĠSharedPreferences Helper Ġ{ ĊĠĠĠ Ġprivate Ġconst Ġval ĠKEY _ SELECTED _ LOCATION Ġ= Ġ" selected _ location " ĊĊĠĠĠ Ġprivate Ġfun Ġget Prefs ( context : ĠContext ): ĠSharedPreferences Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġcontext . get SharedPreferences (" com . f red rik bo gg . weather app ", ĠContext . MODE _ PRIVATE ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġget Selected Location ( context : ĠContext ): ĠSelected Location ? Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġjson : ĠString ? Ġ= Ġget Prefs ( context ). getString ( KEY _ SELECTED _ LOCATION , Ġ"") ĊĠĠĠĠĠĠĠ Ġreturn ĠGson (). fromJson ( json , ĠSelected Location :: class . java ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġsave Selected Location ( context : ĠContext , Ġselected Location : ĠSelected Location ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġjson Ġ= ĠGson (). toJson ( selected Location ) ĊĠĠĠĠĠĠĠ Ġget Prefs ( context ). edit (). putString ( KEY _ SELECTED _ LOCATION , Ġjson ). apply () ĊĠĠĠ Ġ} Ċ }