0

how to resolve this error I am trying to resole this error but not able to resolve this error I am Passing Id from Adapter And want to retrieve it in payfee activity please guide how to resolve I am a beginner please don't mark it duplicate

//Adapter
  Intent intent=new Intent(holder.itemView.getContext(),PayfeeActivity.class);
            intent.putExtra("id",id);
            holder.itemView.getContext().startActivity(intent);


//PayfeeActivity
 id=getIntent().getStringExtra("id");
  private void loadsdetail() {
    DatabaseReference ref= FirebaseDatabase.getInstance().getReference("Users");
    ref.child("Students").child(id).addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(@NonNull DataSnapshot ds) {
            //  for(DataSnapshot ds:snapshot.getChildren())
            // {
          //  String Nam=""+ds.child("name").getValue();
          //  String accounttype=""+ds.child("accounttype").getValue();
          //  String shopProfile=""+ds.child("sprofiles").getValue();
           // String Email=""+ds.child("email").getValue();
          //  String Shopaddress=""+ds.child("address").getValue();

            Sfphon=""+ds.child("fatherphon").getValue();

           // shopnametv.setText(Shopname);
            phon.setText(Sfphon);
          //  emailtv.setText(Email);
          ////  addresstv.setText(Shopaddress);

            try{

           //     Picasso.get().load(shopProfile).placeholder(R.drawable.ic_store_gray).into(sprofile);

            }catch (Exception e)
            {
              //  sprofile.setImageResource(R.drawable.ic_store_gray);
            }

            // }
        }

        @Override
        public void onCancelled(@NonNull DatabaseError error) {

        }
    });
   }

enter image description here

  • what did you get when u run this code ?? – D_K Apr 15 '21 at 06:06
  • Can't pass null for argument 'pathString' in child() – jameel khan Apr 15 '21 at 06:11
  • Are you sure that "id" is not null? – Alex Mamo Apr 15 '21 at 06:26
  • It’s a good idea to include structures as *text*, not links and images. That way, if they are needed in an answer, they can be copied and pasted. To get your Firebase structure, use the Firebase console->Export JSON and copy and paste a snippet of your structure. Also, please update the question with what troubleshooting you've done. Did you step through the code line by line so see which line doesn't work and what the vars are before that line? – Jay Apr 16 '21 at 16:25

1 Answers1

1

You need to get intent extra like this

intent.getStringExtra("id")

Before

ref.child("Students").child(id).addListenerForSingleValueEvent(new ValueEventListener()

After

ref.child("Students").child(intent.getStringExtra("id")).addListenerForSingleValueEvent(new ValueEventListener()

I hope this work.

For further reference view this https://stackoverflow.com/a/4233898/9502601

Shayan Samad
  • 294
  • 1
  • 10