Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
時間を SharedPrefs に保存する最良の方法は何ですか? SharedPrefs から取得した後に時刻を時刻に戻す必要があるため、int または string に変換するのが最善でしょうか。
保存する:
SharedPreferences prefs; SharedPreferences.Editor editor = prefs.edit(); editor.putLong("time", Date.getTime()); editor.commit();
取得するには:
Date myDate = new Date(prefs.getLong("time", 0));