Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save CHLibrarian/41275c8d6cfa5df6d2f7 to your computer and use it in GitHub Desktop.
Save CHLibrarian/41275c8d6cfa5df6d2f7 to your computer and use it in GitHub Desktop.
ContextHub Application Services Vault Item Create (Android)
class Person implements Serializable {
String name;
String title;
ArrayList<String> nicknames;
int heightInInches;
int age;
public Person(String name, String title, ArrayList<String> nicknames, int heightInInches, int age) {
this.name = name;
this.title = title;
this.nicknames = nicknames;
this.heightInInches = heightInInches;
this.age = age;
}
@Override
public String toString() {
return String.format("name: %s\ntitle: %s\nnicknames: %s\nheightInInches: %s\nage: %s",
name, title, nicknames, heightInInches, age);
}
}
//...
// Add Kramer's information to the vault
ArrayList<String> nicknames = new ArrayList<String>(Arrays.asList(new String[]{"Hipster Doofus", "K-Man"}));
Person person = new Person("Cosmo Kramer", "CEO, Kramerica Industries", nicknames, 75, 32);
VaultProxy<Person> proxy = new VaultProxy<Person>();
proxy.createDocument(person, Person.class, new String[]{"sample"}, new VaultCallback<Person>() {
@Override
public void onSuccess(VaultDocument<Person> result) {
Log.d(TAG, result.getDataObject().toString());
}
@Override
public void onFailure(Exception e) {
Log.d(TAG, e.getMessage());
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment