android - Retrieve Firebase Data saved with push() -
i have firebase database.when im saving data used push()
generate auto increment key.
now db this
recipe{ categories{ -kjxzi0jbe1sy5ccfgqf{ name: "sri lankan" } } }
when im retrieving data got error
w/classmapper: no setter/field -kjxz53rlic4rzpvjk48 found on class com.kosala.uyamu2.data_category
this data_category
bean
public class data_category { string name; public data_category() {} public data_category(string name) { this.name = name;} public string getname() { return name;} public void setname(string name) { this.name = name;}}
this retrieving data
mdatabase.child("recipe").child("categories").addlistenerforsinglevalueevent(new valueeventlistener() { @override public void ondatachange(datasnapshot datasnapshot) { data_category data = datasnapshot.getvalue(data_category.class); log.d("name", data.getname()); } @override public void oncancelled(databaseerror databaseerror) { } });
can 1 me here.thanks.
use
public void ondatachange(datasnapshot datasnapshot) { (datasnapshot data : datasnapshot.getchildren()) data_category category = data.getvalue(data_category.class); } }
Comments
Post a Comment