'My data is not getting uploaded in firebase it has internet access creating user with firebase auth that also not getting uploaded & nor child created
Below is the java file of this activity. I want my name and email to be stored in realtime database and sign in with firebase auth, but neither is working. I followed the step like internet access and firebase steps, but still the data isn't getting uploaded signup.java is the files name .
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
public class signup extends AppCompatActivity {
EditText fullname, email, password;
Button btSign_in, btregister;
FirebaseDatabase firebaseDatabase;
DatabaseReference reference;
FirebaseAuth auth ;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_signup);
fullname = findViewById(R.id.etfullname);
email = findViewById(R.id.etemail);
password = findViewById(R.id.etPassword);
btSign_in = findViewById(R.id.btSignUp);
btregister = findViewById(R.id.btregister);
btSign_in.setOnClickListener(view -> {
Intent intent = new Intent(getApplicationContext(), Login.class);
startActivity(intent);
});
created the child but still it doesn't appear still it doesn't get uploaded
FirebaseDatabase.getInstance().getReference().child("User");
btregister.setOnClickListener(view -> {
String fullname_ = fullname.getText().toString();
String email_ = email.getText().toString();
String password_ = password.getText().toString();
if (!fullname_.isEmpty()) {
fullname.setError(null);
fullname.setEnabled(false);
if (!email_.isEmpty()) {
email.setError(null);
email.setEnabled(false);
if (!password_.isEmpty()) {
password.setError(null);
password.setEnabled(false);
if (email_.matches("^[a-zA-Z0-9_!#$%&’*+/=?`{|}~^.-]+@[a-zA-Z0-9.-]+$")) {
firebaseDatabase = FirebaseDatabase.getInstance();
reference = firebaseDatabase.getReference("User");
String fullname_s = fullname.getText().toString();
String email_s = email.getText().toString();
String password_s = password.getText().toString();
storingdata storingdatass = new storingdata(fullname_s, email_s);
reference.child(email_s).setValue(storingdatass);
auth = FirebaseAuth.getInstance();
auth.createUserWithEmailAndPassword(email_s, password_s)
.addOnCompleteListener(task -> {
if (task.isSuccessful()) {
Toast.makeText(getApplicationContext(), "Register_Successfully", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(getApplicationContext(), Login.class);
startActivity(intent);
Log.d("LOG", "User regestered in authentication");
}
else {
// Registration failed
Toast.makeText(
getApplicationContext(),
"Registration failed!!"
+ " Please try again later",
Toast.LENGTH_LONG)
.show();
}
});
} else {
email.setError("Invalid email");
}
} else {
password.setError("please enter your password");
}
} else {
email.setError("please enter your email");
}
}
else {
fullname.setError("please enter the fullname");
}
});
}
}
plz plz help me its imp and I have tried many ways but still it isn't working I have created the child but nothing gets uploaded
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|