i retrieved username from firebase database i want to store it in global variable,but there is problem with...
up vote
-1
down vote
favorite
iam new to stackoverflow kindly correct me if anything wrong.
i am trying to store username which is retrieved from fire database in to a global variable
FirebaseUser uid=FirebaseAuth.getInstance().getCurrentUser();
Uid=uid.getUid();
mDatabaseRef = FirebaseDatabase.getInstance().getReference();
mDatabaseRef.child("Users").child(Uid).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
User user = dataSnapshot.getValue(User.class);
location=user.getLocation();
String loc = location.split(",");
loc[0] = loc[0].substring(0, 7);
Toast.makeText(MainActivity.this, loc[0], Toast.LENGTH_SHORT).show();
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
i want to use string -location out of addValueEventListener method ,is there any way like any approach to use location as global variable...plz help me
New contributor
SriRam Govardhanam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
-1
down vote
favorite
iam new to stackoverflow kindly correct me if anything wrong.
i am trying to store username which is retrieved from fire database in to a global variable
FirebaseUser uid=FirebaseAuth.getInstance().getCurrentUser();
Uid=uid.getUid();
mDatabaseRef = FirebaseDatabase.getInstance().getReference();
mDatabaseRef.child("Users").child(Uid).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
User user = dataSnapshot.getValue(User.class);
location=user.getLocation();
String loc = location.split(",");
loc[0] = loc[0].substring(0, 7);
Toast.makeText(MainActivity.this, loc[0], Toast.LENGTH_SHORT).show();
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
i want to use string -location out of addValueEventListener method ,is there any way like any approach to use location as global variable...plz help me
New contributor
SriRam Govardhanam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
iam new to stackoverflow kindly correct me if anything wrong.
i am trying to store username which is retrieved from fire database in to a global variable
FirebaseUser uid=FirebaseAuth.getInstance().getCurrentUser();
Uid=uid.getUid();
mDatabaseRef = FirebaseDatabase.getInstance().getReference();
mDatabaseRef.child("Users").child(Uid).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
User user = dataSnapshot.getValue(User.class);
location=user.getLocation();
String loc = location.split(",");
loc[0] = loc[0].substring(0, 7);
Toast.makeText(MainActivity.this, loc[0], Toast.LENGTH_SHORT).show();
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
i want to use string -location out of addValueEventListener method ,is there any way like any approach to use location as global variable...plz help me
New contributor
SriRam Govardhanam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
iam new to stackoverflow kindly correct me if anything wrong.
i am trying to store username which is retrieved from fire database in to a global variable
FirebaseUser uid=FirebaseAuth.getInstance().getCurrentUser();
Uid=uid.getUid();
mDatabaseRef = FirebaseDatabase.getInstance().getReference();
mDatabaseRef.child("Users").child(Uid).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
User user = dataSnapshot.getValue(User.class);
location=user.getLocation();
String loc = location.split(",");
loc[0] = loc[0].substring(0, 7);
Toast.makeText(MainActivity.this, loc[0], Toast.LENGTH_SHORT).show();
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
i want to use string -location out of addValueEventListener method ,is there any way like any approach to use location as global variable...plz help me
New contributor
SriRam Govardhanam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
SriRam Govardhanam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
SriRam Govardhanam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 3 hours ago
SriRam Govardhanam
11
11
New contributor
SriRam Govardhanam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
SriRam Govardhanam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
SriRam Govardhanam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
SriRam Govardhanam is a new contributor. Be nice, and check out our Code of Conduct.
SriRam Govardhanam is a new contributor. Be nice, and check out our Code of Conduct.
SriRam Govardhanam is a new contributor. Be nice, and check out our Code of Conduct.
SriRam Govardhanam is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53400792%2fi-retrieved-username-from-firebase-database-i-want-to-store-it-in-global-variabl%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown