-
Notifications
You must be signed in to change notification settings - Fork 10
Preferences listing crashes with non-string types on Android #39
Copy link
Copy link
Closed
Description
Problem
When a preference is stored with a non-string type (e.g., int, bool, double) via POST /api/preferences/{key} with type: "int", the GET /api/preferences listing endpoint crashes on Android with:
java.lang.Integer cannot be cast to java.lang.String
This happens because HandlePreferencesList always reads values via Preferences.Get(key, (string?)null), but Android's SharedPreferences stores typed values natively and throws ClassCastException when you read an int as a string.
The crash causes all preferences to disappear from the listing, not just the non-string one, since the entire handler fails.
Root Cause
HandlePreferencesSetcorrectly stores typed values (int, bool, double, float, long, datetime)HandlePreferencesListalways reads back asstring, which fails on AndroidHandlePreferencesGetalso defaults tostringwhen notypequery param is specified
Expected Behavior
Listing and getting preferences should auto-detect the stored type and return the value regardless of its type.
Platform
Android only (iOS/macOS/Windows store all MAUI Preferences as strings internally).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels