In the Firebase Storage, I have a folder named uploads/. Inside that folder, I have multiple folders named after the userIds of the registered users.
This is what I'm trying to do. When the user enters the 'ProfileActivity', the code looks in the Firebase Database if there is any folder named after the userId of that user under the uploads/ folder. And then runs code accordingly if the folder exists or not.
This is what I have done so far, but here the addValueEventListener is not resolved. Am I doing it the right way? What I'm missing here?
public class ProfileActivity extends AppCompatActivity {
private FirebaseAuth mAuth;
private StorageReference mStorageRef;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_profile);
mAuth = FirebaseAuth.getInstance();
mStorageRef = FirebaseStorage.getInstance().getReference("uploads");
}
@Override
protected void onStart() {
super.onStart();
FirebaseUser user = mAuth.getCurrentUser();
String userID = user.getUid();
if (user.isEmailVerified()) {
StorageReference userFolder = mStorageRef.child(userID);
userFolder.addValueEventListener(new ValueEventListener() {
@Override
void onDataChange(DataSnapshot snapshot) {
if (snapshot.exists()) {
// run some code
} else {
//Code
}
}
});
}
}
}