首页 > 解决方案 > 如何从 FireStore 读取 ArrayList?

问题描述

如果我的 FirebaseFireStore 中有完整的 ArrayList,如何将其读取到本地 ArrayList,我的意思是我应该使用什么函数?

public void stuArr() {

    noteRef.get()
            .addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>() {
                @Override
                public void onSuccess(DocumentSnapshot documentSnapshot) {
                    if (documentSnapshot.exists()) {
                        studentArrayList.add(documentSnapshot.getString("studentArrayList"));
                    }
                }
            })
            .addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception e) {
                    Toast.makeText(getActivity() , "Error!", Toast.LENGTH_SHORT).show();
                    Log.d("TAG", e.toString());
                }
            });
}

标签: javafirebaseandroid-studioarraylistgoogle-cloud-firestore

解决方案


推荐阅读