问题:
I have an ArrayList
with custom objects.我有一个带有自定义对象的ArrayList
。 Each custom object contains a variety of strings and numbers.每个自定义对象均包含各种字符串和数字。 I need the array to stick around even if the user leaves the activity and then wants to come back at a later time, however I don't need the array available after the application has been closed completely.即使用户离开活动然后想要稍后再回来,我也需要阵列保持住状态,但是在应用程序完全关闭之后,我不需要阵列可用。 I save a lot of other objects this way by using the SharedPreferences
but I can't figure out how to save my entire array this way.我通过使用SharedPreferences
以这种方式保存了许多其他对象,但是我不知道如何以这种方式保存我的整个数组。 Is this possible?这可能吗? Maybe SharedPreferences
isn't the way to go about this?也许不是SharedPreferences
可以解决这个问题? Is there a simpler method?有没有更简单的方法?
解决方案:
参考一: https://stackoom.com/question/Tc4D参考二: Save ArrayList to SharedPreferences