android - Firebase null pointer exception -


i getting null pointer exception in firebase knows there not value database reference giving wants when value generated shown automatically... wants single value everytime created on firebase giving me null pointer exception on line string val =.....

please me ...

final databasereference dtt = database.getreference("/trial/trials/");     dtt.addvalueeventlistener(new valueeventlistener() {          @override         public void ondatachange(datasnapshot datasnapshot) {             string val= datasnapshot.child("myvalue").getvalue().tostring();             if(val!=null)             {                 log.e("not null------","---------------");             }else             {                 log.e("null------","---------------");             }         }          @override         public void oncancelled(databaseerror databaseerror) {          }     }); 

please me.....please ..

you using getvalue() in wrong way. should be

string val= datasnapshot.child("myvalue").getvalue(string.class); 

to check, if value exists can convert datasnapshot hashmap, this

hashmap<string, object> hashmap = (hashmap) datasnapshot.getvalue(); string val= hashmap.get("myvalue"); 

Comments

Popular posts from this blog

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -