是否可以使用SharedPreferences
附加我存储的数据而不是覆盖每个条目?
public void onClick(View argument) {
// TODO Auto-generated method stub
if(argument==save)
{
SharedPreferences sp=getSharedPreferences("userInfo", 0);
SharedPreferences.Editor spe=sp.edit();
spe.putInt("ID",Integer.parseInt(enteredID.getText().toString()));
spe.putString("name", enteredName.getText().toString());
spe.putString("password",enteredPassWord.getText().toString());
spe.putInt("age", Integer.parseInt(enteredAge.getText().toString()));
spe.commit();
}
}
答案 0 :(得分:0)
获取您在SharedPreferences中放置的最后一个值,并与新的值连接,例如:
String prevString = spe.getString ("name", "");
spe.putString("name", prevString.concat(enteredName.getText().toString()));