My application is used on multiple platforms so it saves it preferences to a file (rather than to the standard Android SharedPreferences).
Is there any easy of reusing the PreferenceActivity to save preferences to a file or is it a case of creating a whole new activity to do the job? If the latter is the case is there a layout I can use that will make the activity look like the normal preferences screen? PreferenceActivity uses com.android.internal.R.layout.preference_list_content but this doesn’t appear to be available to apps for reuse.
Not really. I mean, you could subclass
SharedPreferences, rip the guts out, and map it to your own data model, but that would be far, far worse for maintainability than just usingSharedPreferencesin the first place.It’s just a
ListView. It will take you a lot more time to do this than to just useSharedPreferences.Sure it is. If you have the SDK installed, it’s on your hard drive right now. Look in
$ANDROID_HOME/platforms/$API/data/res/layout, where$ANDROID_HOMEis where you have the SDK and$APIis some API (e.g.,android-2.1).