【发布时间】:2020-03-16 07:17:18
【问题描述】:
我希望应用每天执行一次特定的操作,即用户在一天中第一次打开应用时。 为此,我想在 SharedPreference 中存储一个日期。 但它只存储 int、boolean、string 等。
/*
I'm showing my logic here. If there is better way plz tell me!!!
I will give some by default value like 00/00/0000 for initialization.
The first time user starts the app then I will do that particular work and initialize sharedPreference by current date 16/03/2020.
If user again opens app by same date I don't do that work(By checking curdate and sharedPreference date).
If user opens app on another date I check currentDate and sharedPreference date, if they are different I will do that work and edit the sharedPreference by that day.
*/
那么告诉我如何在 sharedPreference 中存储日期?
【问题讨论】:
-
将日期转换为字符串
-
以毫秒为单位节省时间
-
请打开我的问题。我的问题不一样!!!
-
@Aayushdual 如果您认为您的问题有所不同,edit 您的问题将准确解释它与标记的副本有何不同。这将允许人们投票重新开放。
-
好的,谢谢!我等了 90 分钟再问一次!!
标签: android date logic sharedpreferences