how to pass value data between classes/activity in Android?

后端 未结 6 2024
情书的邮戳
情书的邮戳 2021-01-03 13:12

For example i have activity1, activity2, activity3 and lastly valueAllActivity? how do I pass the data from activity1, activity2, activity3 to --> valueAllActivity?

6条回答
  •  一向
    一向 (楼主)
    2021-01-03 13:29

    You have several options:

    1. Use intents to pass data when you move between activities.
    2. Use a global application state bean, which you create by extending the Application class, which you can then access in your activity by calling the getApplication() method.
    3. Use the SharedPreferences api if the shared data is something that will be provided by the user.
    4. Persist data to the SQLite database and retrieve it in each Activity, if you want the data to be available even when the application is shutdown and restarted.

    Read the documentation for all available ways in which you can store and retrieve data in your application.

提交回复
热议问题