Skip to content Skip to sidebar Skip to footer

Realm Database Read Data From Android

I am new to realm database so need some help. When I kill my app then come back to the app again, I am unable to retrieve the data which was saved in retrofit. Insertion is working

Solution 1:

you have inserted data but when app is restart you have to get data from database

 realm.beginTransaction();
 realmCities = realm.copyToRealm(clientContactList);
 realm.commitTransaction();

when restart the app you have to get data from database like :

RealmResults<ClientContact> realmCities= realm.where(ClientContact.class).findAllAsync();    
                        //fetching the data
        realmCities.load();

and after that you have to check condition

if(realmCities!=null && realmCities.size()>0){
    Log.e("realmCities",""+realmCities.size());
}else{
    callJSON();
}

Post a Comment for "Realm Database Read Data From Android"