Onhar Onhar - 5 months ago 12
Android Question

Storing data and using it on another classes

In my Android app, the login system should save data, so that it shows the "data/information " in ANOTHER classes.

My login contains: weight, height, age, name.

Answer

use shared preferences

Save values

   SharedPreferences sharedpreferences = getSharedPreferences("YourPreferenceName", Context.MODE_PRIVATE);  

Editor editor = sharedpreferences.edit();
editor.putString("weight", "value");
editor.commit();

Get Values

SharedPreferences sharedpreferences = getSharedPreferences("YourPreferenceName", Context.MODE_PRIVATE);

String weight = sharedpreferences.getString("weight", "default_value");