Different ways to convert between keys and strings are described in App Engine docs here . In short, to get a lowercase version of a key, you want to do this:
String employeeKeyStr = KeyFactory.keyToString(employeeKey);
To convert it back to a key, which you can get with ds.get() , you have to do this:
Key employeeKey = KeyFactory.stringToKey(employeeKeyStr);
The string version that you retrieve with .toString() is a human-readable version of the key, not intended to be transmitted as a machine-readable identifier.
Of course, if you are going to transfer keys around your code, there is no need to convert them into strings. Conversely, if you want to use them as external identifiers, you probably want to read the rest of the related section, which discusses ancestors, identifiers, and names; most of the time when you want to pass identifiers, the name or identifier will be sufficient and shorter and more readable than the full key.
source share