Passing data between Fragments in the same Activity

前端 未结 7 1443
清歌不尽
清歌不尽 2021-02-09 12:01

Am working in a project with an Activity that host many fragments. Now I need to share some data (integers, strings, arraylist) between these fragments.

First time i use

7条回答
  •  北荒
    北荒 (楼主)
    2021-02-09 12:37

    We can share the Data between fragments in 2 ways.

    1. By Using Bundle

    2. By using Persistence Storage

    By Using Bundle:-

    Bundle bundle=new Bundle();
    bundle.putString("firstName",Fist);
    bundle.putString("LastName",lastN);
    

    Second Persistence Storage :- this you can check how to store Data in Persistence Storage. Hope it will work for you

提交回复
热议问题