JAVA安卓开发SP存储

在准备存储时候,第一第二句添加:

SharedPreferences sp=getSharedPreferences("abc",MODE_PRIVATE);

SharedPreferences.Editor editor=sharedPreferences.edit();

存储语句接在上面两句:

editor.putString("xxx","zzz");

还有以下语句:

putInt   putLong putFloat…………

editor.commit();[此语句必要]

xxx为名字,zzz为该名字的内容;

准备调用的时候,第一句添加:

SharedPreferences sp=getSharedPreferences("abc",MODE_PRIVATE);

调用语句接在上面一句:

String xx=sp.getString("xxx","yyy");

还有以下语句:

getInt  getLong get Float…………

xx为调用xxx的内容,如果需要更改内容,将yyy改为需要更改的内容,调用的话,删去yyy。

猜你喜欢

转载自blog.csdn.net/jtsqrj/article/details/74991337