I am using this datepreference picker:
https://mikeburnscoder.wordpress.com/2010/09/27/datepreference-an-android-library/
I start the picker in my preferences screeen via this code:
<com.Test.preference.DatePreference
android:key="start_date"
android:title="Start at"
android:defaultValue="" />
This is working well. But I cannot find out how to set a default date.
Now it start with 1. Jan 1970. But I want it to set to current date.
I tried it via
android:defaultValue="12.09.2011"
But this lets the app crash.
I have never set defaults of dates in xml. I assume that it is looking for a long value that represents the # of millis since 01/01/1970. So you’re going to need some long string of numbers.
here is an example :
1315868978As for how you can default it to the current date and time. I don’t think you can do this from xml. But in your java you could use System.currentTimeInMillis(). That would like something like this
prefs.getLong("time", System.currentTimeInMillis());Edit: I missed the fact that you were using a library. When I follow your link it looks you you formated the default wrong”
You need to do year first, not last.