1.存入
SharedPreferences sharedPre=getSharedPreferences("Image", MODE_PRIVATE);
SharedPreferences.Editor editor=sharedPre.edit();
Bitmap bit = null;
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
bit.compress(Bitmap.CompressFormat.JPEG,50,byteArrayOutputStream);
String headimg = new String(Base64.encodeToString(byteArrayOutputStream.toByteArray(),Base64.DEFAULT));
editor.putString("icon",headimg);
editor.commit();
2.取出
Bitmap bitmap = null;
SharedPreferences sharedPre=getSharedPreferences("Image", MODE_PRIVATE);
String icon = sharedPre.getString("icon", "");
if(icon != "") {
byte[] decode = Base64.decode(icon.getBytes(), 1);
bitmap = BitmapFactory.decodeByteArray(decode, 0, decode.length);
imageView.setImageBitmap(bitmap);
}