Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
498 views
in Technique[技术] by (71.8m points)

shared preferences in android

how to strore data in shared preferences in table format

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

For store the values using shared preference use below code

SharedPreferences prefs=getSharedPreferences("Key", 0);
          Editor e=  prefs.edit();
           e.putString("Name", "AAA");
           e.commit();

For retrieve the shared prefs value use below code

SharedPreferences prefs=getSharedPreferences("Key", 0);
          String s= prefs.getString("Name", "");

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...