2 ssummeraw ssummeraw 于 2013.09.16 15:54 提问

把Bundle object保存到shared preference中

程序中有2个Activity
Activity1

Activity2
Activity1:

Intent intent= new Intent(Activity1.this,Acivity2.class);
Bundle b=new Bundle();      
b.putParcelableArrayList("actionArray", (ArrayList<? extends Parcelable>) AllListArray.get(0)); 
b.putParcelableArrayList("comedyArray", (ArrayList<? extends Parcelable>) AllListArray.get(1));
b.putParcelableArrayList("loveArray", (ArrayList<? extends Parcelable>) AllListArray.get(2));
b.putParcelableArrayList("classicsArray", (ArrayList<? extends Parcelable>) AllListArray.get(3));
b.putParcelableArrayList("familyArray", (ArrayList<? extends Parcelable>) AllListArray.get(4));

intent.putExtras(b);             
startActivity(intent); 

Activity2:

public List<Movie> actionArray;
     public List<Movie> comedyArray;
     public List<Movie> loveArray;
     public List<Movie> classicsArray;
     public List<Movie> familyArray;
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle recdData = getIntent().getExtras();
        if(recdData!=null) {
            actionArray=recdData.getParcelableArrayList("actionArray");
            comedyArray=recdData.getParcelableArrayList("comedyArray");
            loveArray=recdData.getParcelableArrayList("loveArray");
            classicsArray=recdData.getParcelableArrayList("classicsArray");
            familyArray=recdData.getParcelableArrayList("familyArray");
        }
    }

我想把 Bundle(recdData)存储在 Activity2 中的 Sharedpreferences 中,如何实现?

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!