How to store google authenticated user profile picture in firebase android? -


how put user default profile picture(who authenticated google) firebase storage?

private storagereference stref;  private databasereference userdb;  private firebaseauth mauth;   users users1 = new users(mauth.getcurrentuser().getdisplayname(),mauth.getcurrentuser().getemail()                                                 ,mauth.getcurrentuser().getuid(),                                                 new simpledateformat("yyyy-mm-dd").format(new date()),studydetails,mauth.getcurrentuser().getphotourl());                                         userdb.child(mauth.getcurrentuser().getuid()).setvalue(users1); 

this has failed store in database

you can access user picture :

firebaseuser user = firebaseauth.getinstance().getcurrentuser();  if (user != null) {     uri photourl = user.getphotourl(); } 

here auth user documentation.

then can use lib glide or picasso display it.

set user picture :

mdatabase.child("users").child(userid).child("photourl").setvalue(photourl); 

retrieve other user picture :

mdatabase.child("users").child(userid).child("photourl").addlistenerforsinglevalueevent(new valueeventlistener() {     @override     public void ondatachange(datasnapshot datasnapshot) {         string photourl = (string) datasnapshot.getvalue();     }      @override     public void oncancelled(firebaseerror firebaseerror) {      } }); 

here realtime database documentation.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

.htaccess - ERR_TOO_MANY_REDIRECTS htaccess -