keeping a variable value across all android activities

前端 未结 5 1124
醉话见心
醉话见心 2020-12-06 12:25

I have a database with one row of data that will be used across a number of activities. I need to be able to keep the row id available in all activites so I can read and wri

5条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-06 12:59

    Here you want to get mRowId values from all activity and it is primitive types, So

    Either use Shared Preferences for store data or make your member field as a static globally, Then you can use this data in your whole application life cycle..

    EDIT: Also you can use Application class as a singleton for your application and create field mRowId in this class and also make getter setter method for this field..

提交回复
热议问题