gpt4 book ai didi

java - Android - 记住日期的最佳方式

转载 作者:行者123 更新时间:2023-12-01 22:22:49 24 4
gpt4 key购买 nike

记住日期的最佳方法是什么?我的意思是,我想保存应用程序启动时的最后日期。我想使用此信息来检查应用程序的运行时间是否超过一天。我正在考虑将日期保存在 .txt 文件中,但也许有更好的方法来做到这一点?

最佳答案

您可以将其保存在SharedPreferences中.

SharedPreferences spref = PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor editor = spref.edit();
editor.putInt("lastStartTime", System.currentTimeMillis());
// Commit the edits!
editor.commit();

关于java - Android - 记住日期的最佳方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29399397/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com