I can’t figure out how to save and read data using google app engine. This code does not compile but should give you an idea of what I want to do. The only thing that I can’t seem to figure out is how to create my own key from a string….
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
Entity article = new Entity("Article", "keyThatIMadeUp");
article.setProperty("articleHTML", "this is where the article html goes");
datastore.put(article);
try {
Entity articleRetrieved = datastore.get(Key("keyThatIMadeUp"));
}
catch (EntityNotFoundException e) {
System.out.println("data not found");
}
Any help would be great thanks!
Keys embed the type of entity that they’re a key for. So to reconstruct a key from parts, you need to provide the name of the Entity type. In your case, you’re looking for something like