Skip to main content

Posts

Showing posts with the label default

Android Preferences: How to load the default values when the user hasn"t used the preferences-screen?

I am using a PreferenceActivity to let the user set some values. I am feeding it the xml file with the defined preferences. I have set all the android:defaultValue="" for them. When I start my application, I need the preferences, or if they are not set yet manually, I want the default values: SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); boolean value = prefs.getBoolean("key"), false); However, when android:defaultValue="true" I still get false . So, it looks like the defaultValues set in the XML are not used anywhere but when initializing the preferences-screen. I don't want to hardcode the default values in the getBoolean() method. So, is there a way get the default-values with only defining these in 1 place?

PHP/MySQL - store default text in database or in a file?

OK so I am creating a system where whenever a shop signs up, they get 10 default slides that they can then customize later. The default slide data is just a starting point for them. But I have to assume a lot of shops will not log in and update the information, they just want something up ASAP. So say for the Dashboard slide, every shop starts out with the same heading and text until they go in and update it themselves. Do I insert it in the database, like so: id | slide_id | user_id | headline | text 1 | 1 | 1000 | ... | .... 2 | 1 | 1001 | ... | .... So the database will contain many duplicates of that headline and text since it is the default. Is that a good idea? Or do I do something like this: define("DEFAULT_TEXT", "The text goes here and just used once in a file."); $text = ($stmt->num_rows < 1 ? DEFAULT_TEXT : $text); so I have a query that searches through my slide_data table to see if anything exists for tha