I have declared my ViewModel as follows, where I use set method to store the data and get to fetch the data:

```
public class DataListViewModel extends ViewModel
{
    private List<Object> dataList;

    public DataListViewModel(){
        dataList = new ArrayList<>();
    }

    void setDataList(List<Object> dataList) {
        this.dataList = dataList;
    }

    List<Object> getDataList() {
            return dataList;
    }
}

```

I have declared the view model as follows:

```
@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_saved_recipes);

    // Defining view model to store saved recipes data
    viewModel = ViewModelProviders.of(this).get(DataListViewModel.class);

    if (savedInstanceState != null)
    {
       dataList = viewModel.getDataList();

       if (dataList == null)
       {
           Log.i("SavedRecipes", "View Model not working");
       }
       else
       {
           Log.i("SavedRecipes", "ViewModel" + (viewModel.getDataList()));
       }

    }
}

```

In the onSavedInstanceState of my Activity I am calling the set method to save the data:

```
viewModel.setDataList(dataList);

```

As shown in onCreate when I call the get method of the viewmodel I am getting a blank object though while setting dataList is not empty