gpt4 book ai didi

java - 如何获取保存到文本文件的最后一个整数并将其显示在 Android 的 TextView 中?

转载 作者:行者123 更新时间:2023-12-01 11:35:06 25 4
gpt4 key购买 nike

我正在将 1-10 之间的随机数字保存到文本文件中,并且希望将文本文件中最后保存的数字显示到 TextView 中,以便用户可以看到它。

如何查找文本文件中最后保存的值?有什么功能吗?

提前谢谢您!

最佳答案

为什么不使用共享首选项?

SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(app);
// get the current in value or 0 if it's not set
int anInt = preferences.getInt("MY_INT", 0 /* default value */);
// blah
// save the incremented int.
preferences.edit().putInt("MY_INT", anInt++).commit();

关于java - 如何获取保存到文本文件的最后一个整数并将其显示在 Android 的 TextView 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30086972/

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