-1

I stored a number in a field of a document and want to retrieve it but I get the following error: String resource ID #0x1

I am using this method to retrieve the number. Is the number stored in Firestore as Long, Integer or Double? I didn't find any answer to that, and how can I resolve this error so I can retrieve the number and use it in my code?

The error is displayed in the Toast line.

Your help is very much appreciated!

Here is my code:

    Integer round;

    private FirebaseFirestore db = FirebaseFirestore.getInstance();
    private CollectionReference roundRef = db.collection("Games");

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

       ...

        roundRef.document(gameId).collection("Round").document("Round").get()
                .addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
                    @Override
                    public void onComplete(@NonNull Task<DocumentSnapshot> task) {
                        if (task.isSuccessful()){
                            DocumentSnapshot document = task.getResult();
                            if (document != null){

                                round = document.getLong("round").intValue();

                                Toast.makeText(PlayInterimResultMainActivity.this, round, Toast.LENGTH_SHORT).show();

                            }
                        }
                    }
                });
...

Kaiser
  • 606
  • 8
  • 22

1 Answers1

2

I found the problem:

The error was in the Toast message, where I didn't transformed the integer into a String value. Here is the right Toast message:

Toast.makeText(PlayInterimResultMainActivity.this, round.toString(), Toast.LENGTH_SHORT).show();

Kaiser
  • 606
  • 8
  • 22