java - My code is retrieving data only from first field of my database. Please see details -


i have written code retrieves` data firebase database.

the problem code retrieving data first field of data in database , not fields.

i want retrieve data each , every field of database.

here's code:

retrieveref = new firebase("https://appname.firebaseio.com/hdetails/");  retrieveref.addchildeventlistener(new childeventlistener() {     @override     public void onchildadded(datasnapshot datasnapshot, string s) {         hdescription = (string) datasnapshot.child("hdescription").getvalue();         himage = (string) datasnapshot.child("himage").getvalue();         hlat = (string) datasnapshot.child("hlat").getvalue();         hlng = (string) datasnapshot.child("hlng").getvalue();         postedattime = (string) datasnapshot.child("postedattime").getvalue();         postedby = (string) datasnapshot.child("postedby").getvalue();         postedondate = (string) datasnapshot.child("postedondate").getvalue();     }      @override     public void onchildchanged(datasnapshot datasnapshot, string s) {      }      @override     public void onchildremoved(datasnapshot datasnapshot) {      }      @override     public void onchildmoved(datasnapshot datasnapshot, string s) {      }      @override     public void oncancelled(firebaseerror firebaseerror) {         toast.maketext(getbasecontext(), firebaseerror.getmessage(),                 toast.length_short).show();     } }); 

here's image of database:

enter image description here

the data getting retrieved last field, i.e. f4452618-a073-4868-a9c6-050b055b4861 every time.

here's build.gradle (module:app):

    apply plugin: 'com.android.application'      android {          compilesdkversion 23         buildtoolsversion "23.0.2"         defaultconfig {             applicationid "com.abc.xyz"             minsdkversion 16             targetsdkversion 23             versioncode 5             versionname "0.4"             multidexenabled true;         }         packagingoptions {             exclude 'meta-inf/license'             exclude 'meta-inf/license-firebase.txt'             exclude 'meta-inf/notice'         }         buildtypes {             release {                 minifyenabled false                 proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro'                 signingconfig signingconfigs.config             }         }     }      dependencies {         compile filetree(dir: 'libs', include: ['*.jar'])         testcompile 'junit:junit:4.12'         compile 'com.android.support:appcompat-v7:23.4.0'         compile 'com.android.support:design:23.4.0'         compile 'com.android.support:cardview-v7:23.4.0'         compile 'com.android.support:recyclerview-v7:23.4.0'         compile 'com.firebase:firebase-client-android:2.3.1'         compile 'com.firebaseui:firebase-ui:0.3.1'         compile 'com.facebook.android:facebook-android-sdk:4.1.0'         compile 'com.google.android.gms:play-services-maps:9.0.0'         compile 'com.google.android.gms:play-services-plus:9.0.0'         compile 'com.android.support:support-v4:23.4.0'         compile 'com.squareup.picasso:picasso:2.5.2'         compile 'com.google.android.gms:play-services-location:9.0.0'         compile 'com.firebase:geofire:1.1.0'         compile 'com.google.firebase:firebase-database:9.0.1'         compile 'io.github.yavski:fab-speed-dial:1.0.4'         compile 'com.google.gms:google-services:3.0.0'     }  apply plugin: 'com.google.gms.google-services' 

here'sbuid.gradle (project: projectname):

buildscript {     repositories {         jcenter()     }     dependencies {         classpath 'com.android.tools.build:gradle:2.1.0'         classpath 'com.google.gms:google-services:3.0.0'          // note: not place application dependencies here; belong         // in individual module build.gradle files     } }  allprojects {     repositories {         jcenter()     } }  task clean(type: delete) {     delete rootproject.builddir } 

what's going wrong here?

please let me know.

sorry, if question seems badly formatted. i'm still beginner here.

try using query class firebase

 databasereference root = firebasedatabase.getinstance().  getreferencefromurl("https://appname.firebaseio.com/hdetails/");   query playlistquery = root.orderbykey();   playlistquery.addchildeventlistener(new childeventlistener() {             @override             public void onchildadded(datasnapshot datasnapshot, string s)             {                  //make sure have empty constructor de-serialize                  yourpojo playlist = datasnapshot.getvalue(yourpojo.class);                 playlist.getname(); // depends on field names                 playlist.getdetails();                 ....             }             @override             public void onchildchanged(datasnapshot datasnapshot, string s) {              }              @override             public void onchildremoved(datasnapshot datasnapshot) {              }              @override             public void onchildmoved(datasnapshot datasnapshot, string s) {              }              @override             public void oncancelled(databaseerror databaseerror) {              }         }); 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

python 3.x - PyQt5 - Signal : pyqtSignal no method connect -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)