Realm-java: How to get the names of all the tables in the Realm database?

Created on 22 Aug 2019  路  3Comments  路  Source: realm/realm-java

Is there a convenient way to get all the RealmObject subclass names in the database?

O-Community T-Help

Most helpful comment

Yes. If you want all of them irrespectively if they are part of the schema or not you can do:

DynamicRealm.getInstance(config).getSchema().getAll().forEach { objSchema -> objSchema.getClassName() }

If you want all that are part of the schema you can do

Realm.getInstance(config).getSchema().getAll().forEach { objSchema -> objSchema.getClassName() }

All 3 comments

Yes. If you want all of them irrespectively if they are part of the schema or not you can do:

DynamicRealm.getInstance(config).getSchema().getAll().forEach { objSchema -> objSchema.getClassName() }

If you want all that are part of the schema you can do

Realm.getInstance(config).getSchema().getAll().forEach { objSchema -> objSchema.getClassName() }

Hey - looks like you forgot to add a T:* label - could you please add one?

Thanks,That is awesome!

ps:

the

forEach { objSchema -> objSchema.getName() }

should be

forEach { objSchema -> objSchema.getClassName() }

馃檪

Was this page helpful?
0 / 5 - 0 ratings