Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think your calls to setPreferenceForKey and preferenceForKey look strange. Where does that <code>null</code> come from. Shouldn't they look like</p> <pre><code>widget.preferenceForKey(dashcode.createInstancePreferenceKey(userIdPrefKey)) widget.setPreferenceForKey(value, dashcode.createInstancePreferenceKey(userIdPrefKey)); </code></pre> <p>Does the syntax with <code>null</code></p> <pre><code>widget.setPreferenceForKey(null, dashcode.createInstancePreferenceKey(userIdPrefKey)) </code></pre> <p>in <code>remove()</code> delete the preference? That would explain you situation I guess. On Update the <code>remove()</code> gets surley called and thus on restart of the widget the preferences are gone.</p> <hr> <p>I guess there is only one way to keep your preferences during an update. Create one preferencekey without relying on dashboard.createInstancePreferenceKey but instead think yourself of a unique key value.</p> <p>In this preferenceKey you could then save all ever entered userids (by any instance) with a growing (say comma seperated) list. When a widget instance is opened an the <code>widget.preferenceForKey(dashcode.createInstancePreferenceKey(userIdPrefKey))</code> isn't already set you could let the user choose one of those by giving him a select or such a thing</p> <p>I was just thinking maybe the update process is nice enough to migrate the preferences to the new verison. Even when you don't remove the preferences I think the widget.identifier (createInstancePreferenceKey) will have changed an thus you can't access the "old" settings.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload