I have been struggling with this for a while, and I simply cannot understand where I am going wrong. I've tried multiple ways - lately adding my own listeners but after that following a somewhat recent tutorial on sending data to firebase, but for some reason I keep running into a similar issue every time -- ie. to me it seems like the setValue doesn't... work?
I'm quite sure that it is something to do with my setup - but I cannot figure out what it is and hopefully someone can help me out.
Latest try is below. I know the listeners rely on toasts which is less than ideal - but none show up at the moment.
Thanks for any help in advance
package com.example.firebase_rb;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Toast;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
public class MainActivity extends AppCompatActivity {
DatabaseReference databaseReference;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
databaseReference= FirebaseDatabase.getInstance().getReference("this is the path");
databaseReference.setValue("here there").addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void unused) {
Toast.makeText(getApplicationContext(), "success", Toast.LENGTH_SHORT).show();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(getApplicationContext(), "failed", Toast.LENGTH_SHORT).show();
}
}).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
Toast.makeText(MainActivity.this, "wtf", Toast.LENGTH_SHORT).show();
}
});
}
}