0

Im storing users location in Arraylist now I want after the click on finish button to store the two ArrayList lat ,ArrayLis lng into SharedPreferences the later to display the data .

Is it possible to do this with Sharedpreferences or is it better to use Sqlite ?

Thanks !

  • you can (https://stackoverflow.com/questions/3876680/is-it-possible-to-add-an-array-or-object-to-sharedpreferences-on-android), but I would personally avoid storing big arrays and polluting the shared preferences. Also if it's important information the shared preferences get erased if the user clears the cache/data of the app, so keep that in mind – Nikos Hidalgo Dec 11 '18 at 12:17
  • Do you want to persist data ? or Do you want to share data between activities ? – varatharajan Dec 11 '18 at 12:27
  • Basically I want persist data ,having one MapsActivity and after the array list is saved user will choose wich array list he wants to be displayed and then I want to display the array list in another MapsActivity . –  Dec 11 '18 at 12:31
  • You can check my answer here https://stackoverflow.com/a/53325509/1496502. It is applicable for any 1D arrays with different datatypes. – Uma Sankar Dec 11 '18 at 13:02
  • Uma Sankar - if I convert double to String how can I later retrieve and convert string to double again ? –  Dec 11 '18 at 13:39

0 Answers0