0

I am new to firebase and i am trying to get a datasnapshot for the location at the specified relative path.However, i am getting error like:

error: cannot find symbol
               result.setResult(DataSnapshot);
                                ^
  symbol: variable DataSnapshot

I don't know what's wrong with the code. Please help.

package com.jstechnologies.helpinghandscloud.Tasks;


import com.android.volley.toolbox.StringRequest;
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.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.Map;



    @Override
    public void run() {

ref.addValueEventListener(new ValueEventListener() {


    @Override
    public void onDataChange(@NonNull @org.jetbrains.annotations.NotNull DataSnapshot snapshot) {
        //Creating task object
               TaskResult result= new TaskResult();
               result.setSuccess(true);
                result.setMessage("Successful");
               result.setResult(DataSnapshot);
                fireOnComplete(result);
    }

    @Override
    public void onCancelled(@NonNull @org.jetbrains.annotations.NotNull DatabaseError error) {

    }
});

    }
}
  • 1
    `DataSnapshot` is a class (or interface, doesn't matter in this context). You can't pass that to a method. You probably meant to pass `snapshot` instead. – Federico klez Culloca Jun 09 '21 at 12:46
  • 1
    result.setResult(DataSnapshot); should most likely be result.setResult(snapshot); As Federico stated, DataSnapshot isn't a value or variable, it's a type – Stultuske Jun 09 '21 at 12:46
  • Federico is right, you must place `snapshot` instead of `DataSnapshot` – Adrixb Jun 09 '21 at 13:12
  • In the result.setResult(); line you should replace DataSnapshot with snapshot – Kleysley Jun 09 '21 at 13:49

0 Answers0