2011-08-11 20 views
1

我有一些首选项(EditText和ListPreference),我必须在XML文件中添加日期首选项。这是可能的,它是否存在于共享首选项中?日期偏好存在吗?

谢谢你的帮助。

回答

3

我很确定没有共享偏好的日期选择器,你很可能必须创建自己的。您可以将日期使用

SharedPreferences.Editor editor = sharedPreferences.edit(); 
    //editor.putLong(key, Long); 
    editor.putLong("thecurrentdate", currentDate.getTime()); 

这将日期存储到偏好然而存入的偏爱,你的情况,你可以将其存储到的EditText偏好。

也许这个职位会帮助你吗? How to store a Date object in SharedPreferences?

希望这有助于!