无法将数据添加到Firebase数据库中

时间:2018-04-17 06:09:30

标签: android firebase firebase-realtime-database

package io.github.httpsabhisheksy.myapplication;

import android.provider.ContactsContract;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.method.TextKeyListener;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;

import java.util.HashMap;
import java.util.Map;

import static android.R.attr.name;
import static io.github.httpsabhisheksy.myapplication.R.id.userSave;

public class EditPersonalAccountInfoActivity extends AppCompatActivity {

EditText NV;
EditText DAV;
EditText HTV;
EditText AgeV;
EditText BGV;
EditText PNV;
EditText AsthamaV;
EditText PregnantV;
EditText RSV;
EditText BSV;
EditText WV;
EditText HV;

Button saveUser;
FirebaseDatabase firebasedatabase;
DatabaseReference databasereference;

FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference myRef = database.getReference("message");


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_edit_personal_account_info);

    saveUser=(Button)findViewById(userSave);
    saveUser.setOnClickListener(new View.OnClickListener(){
        public void onClick(View view){
            saveUserDetails();
        }
    });


}

public void saveUserDetails(){

    NV= ( EditText ) findViewById(R.id.NV);
    /*DAV= ( EditText ) findViewById(R.id.DAV);
    HTV= ( EditText ) findViewById(R.id.HTV);
    AgeV= ( EditText ) findViewById(R.id.AgeV);
    BGV= ( EditText ) findViewById(R.id.BGV);
    PNV= ( EditText ) findViewById(R.id.PNV);
    AsthamaV= ( EditText ) findViewById(R.id.AsthamaV);
    PregnantV= ( EditText ) findViewById(R.id.PregnantV);
    RSV= ( EditText ) findViewById(R.id.RSV);
    BSV= ( EditText ) findViewById(R.id.BSV);
    WV= ( EditText ) findViewById(R.id.WV);
    HV= ( EditText ) findViewById(R.id.HV);*/

    String nv=NV.getText().toString().trim();
    /*String dav=DAV.getText().toString().trim();
    String htv=HTV.getText().toString().trim();
    String Agev=AgeV.getText().toString().trim();
    String pnv=PNV.getText().toString().trim();
    String bgv=BGV.getText().toString().trim();
    String asthamav=AsthamaV.getText().toString().trim();
    String pregnantv=PregnantV.getText().toString().trim();
    String rsv=RSV.getText().toString().trim();
    String bsv=BSV.getText().toString().trim();
    String wv=WV.getText().toString().trim();
    String hv=HV.getText().toString().trim();*/

    FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
    String uid = user.getUid();
    myRef = database.getReference("users/" + uid + "/name");
    myRef.setValue(nv);

    Toast.makeText(this,"function is working",Toast.LENGTH_LONG).show();
}
}

但是使用此代码我没有收到任何错误,但仍然没有数据更新到数据库中。有解决方案吗 我尝试了很多其他方法来向数据库添加数据,但似乎毫无用处。我试图仅通过firebase数据库过滤日志,我在那里写了“W / IInputConnectionWrapper:finishComposingText on inactive InputConnection”这个不寻常的东西

或者请帮我解决任何问题,我已经成功实施了注册和登录流程。我需要分别添加数据作为每个用户的详细信息。

0 个答案:

没有答案