0

I'm looking for an easy way to handle integer and IP-type preference values in a PreferenceActivity. The idea is, to catch the changes in the onSharedPreferenceChanged listener. If the value doesn't fit the required type, it should be either reset to the default value or to the value before the change.

My questions: - how to restore a single value of the shared preferences with the default? - is it possible to get the last value in an easy way?

Thanks in advance!

Thomas

Dark.Rider
  • 381
  • 1
  • 4
  • 17
  • I don't understand your question. Do you have a String and want to save it as an `int` if it is an `int`? Why no just keep the values as a String? – Sam Feb 16 '13 at 16:21
  • No, not exactly. I have some preferences that are integers. For example a tcp-port. As the PreferenceActivity doesn't support integers, i have to take EditTextPreference. I'm looking for an easy way to filter the user input. – Dark.Rider Feb 16 '13 at 18:17
  • Try android:inputType="number" in your preferences xml – Hoan Nguyen Feb 16 '13 at 19:35
  • Thanks!! inputType doesn't show up in eclipse but it works!! – Dark.Rider Feb 16 '13 at 20:47
  • But the question isn't answered yet.. The problem remains for other formatted input (for example ip-adress) – Dark.Rider Feb 16 '13 at 20:55

0 Answers0