how to add another table in existing realm android -
i have database few tables. need add table existing database, don't find ways in migration class.
table persontable = realm.gettable(person.class); table pettable = realm.gettable(pet.class); pettable.addcolumn(columntype.string, "name"); pettable.addcolumn(columntype.string, "type"); long petsindex = persontable.addcolumnlink(columntype.link_list, "pets", pettable); long fullnameindex = getindexforproperty(persontable, "fullname"); (int = 0; < persontable.size(); i++) { if (persontable.getstring(fullnameindex, i).equals("jp mcdonald")) { persontable.getuncheckedrow(i).getlinklist(petsindex).add(pettable.add("jimbo", "dog")); } } version++; }
the example gave above has that
table pettable = realm.gettable(pet.class); pettable.addcolumn(columntype.string, "name"); pettable.addcolumn(columntype.string, "type"); long petsindex = persontable.addcolumnlink(columntype.link_list, "pets", pettable);
note in example, version 1 doesn't have pet table until version 2.
Comments
Post a Comment