开发者

Android - tracking order of my activities

开发者 https://www.devze.com 2023-04-11 16:40 出处:网络
I need to know order, my intents were called one by another. When I start new activity, I append it\'s name into String field. That\'s nice, but I need to preserve this field until my app is run again

I need to know order, my intents were called one by another. When I start new activity, I append it's name into String field. That's nice, but I need to preserve this field until my app is run again (= destroyed by system and then opened anew). But how to preserve field? I was able to preserve only 'key=value' data by StaredPreferences approach, but there is nothing said about fields. Do you know how to achive persisting of this field? I want to omit database storing or file storage, because it is开发者_StackOverflow only String and nothing more complicated.

Thanks


SharedPreferences are perfect for what you are looking for. You said it is a string that is appended after each activity change. Why not just save a shared pref with key "activity_history" and the value is the entire string? I don't think there is a limit on the length of a string you can store.

Use a delimiter in the string to break up the different activities.

0

精彩评论

暂无评论...
验证码 换一张
取 消