Skip to content Skip to sidebar Skip to footer

How Can I Improve This Method Of Loading Objects With ORMLite On Android?

I am loading a set of objects (and their foreign objects) using ormlite 4.35 on Android. It takes (in the emulator) between 16 and 19 seconds for the timing in the getAllCragsWithL

Solution 1:

I'm really surprised that it is taking that long.

    @ForeignCollectionField(eager = true)
    private Collection<Guidebook> guidebooks;
    @DatabaseField(foreign=true, foreignAutoRefresh = true, index=true)
    private uk.co.bmc.rad.models.Location location;
    @DatabaseField(foreign=true,foreignAutoRefresh=true)
    private SubRegion subRegion;

Each of those fields will generate another database query that would take time although I would not expect seconds. ORMLite is not smart about using JOIN to satisfy eager fetched remote objects.

One thing to try is to use the table-config process to work around Android's dog, dog slow reflection implementation when generating DAO implementations. See the docs for that:

http://ormlite.com/docs/table-config

I would be curious if you figure it out although I understand if you need to switch to some other package to get working.


Solution 2:

I think you should consider using a ContentProvider. I have made an application manipulating 2k rows but the query and object regeneration is done in less than 10 sec on the emulator


Post a Comment for "How Can I Improve This Method Of Loading Objects With ORMLite On Android?"