Hi, you said, "You can only associate 1 name-value pair with each node (no Collections-based values are allowed)" And I'm wondering if this is still considered a 1 name-value pair?
Where you can combine two values under one key and recall them like this:
int x, y;
...
prefs.put(POSITION, x + "," + y);
static int X_DEFAULT = 50, Y_DEFAULT = 25;
void baz() {
String position = prefs.get(POSITION, X_DEFAULT + "," + Y_DEFAULT);
int x, y;
try {
int i = position.indexOf(',');
x = Integer.parseInt(coordinates.substring(0, i));
y = Integer.parseInt(position.substring(i + 1));
} catch(Exception e) {
// Value was corrupt, just use defaults
x = X_DEFAULT;
y = Y_DEFAULT;
}
...
}
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi, you said, "You can only associate 1 name-value pair with each node (no Collections-based values are allowed)" And I'm wondering if this is still considered a 1 name-value pair?
Where you can combine two values under one key and recall them like this: