mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-31 14:17:03 +02:00
Clear widget data
This commit is contained in:
@@ -134,6 +134,23 @@ public class Widget extends AppWidgetProvider {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeleted(Context context, int[] appWidgetIds) {
|
||||
try {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
for (int appWidgetId : appWidgetIds) {
|
||||
String prefix = "widget." + appWidgetId + ".";
|
||||
for (String key : prefs.getAll().keySet())
|
||||
if (key.startsWith(prefix))
|
||||
editor.remove(key);
|
||||
}
|
||||
editor.apply();
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
}
|
||||
}
|
||||
|
||||
static void init(Context context, int appWidgetId) {
|
||||
update(context);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user