How to Store Hashmap to android so that it will be reuse when application restart using shared preferences?

后端 未结 5 1966
余生分开走
余生分开走 2020-12-30 06:38

I want to store hashmap to my android application that when restart ,it shows last saved values of hashmap.

HashMap HtKpi=new HashMap&l         


        
5条回答
  •  心在旅途
    2020-12-30 07:08

       @Override
    protected void onSaveInstanceState(Bundle outState) {
        // TODO Auto-generated method stub
        super.onSaveInstanceState(outState);
    }
    

    You can store it here.... This method is called before an activity may be killed so that when it comes back some time in the future it can restore its state.

    And then you can retireve it back from here,,,

    @Override
    protected void onRestoreInstanceState(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onRestoreInstanceState(savedInstanceState);
    }
    

    This method is called after onStart() when the activity is being re-initialized from a previously saved state, given here in savedInstanceState...

    I think that this will help

提交回复
热议问题