如何在Firebase ANDROID数据库中检索以ArrayList形式存储的数据?

时间:2017-04-14 22:20:06

标签: android firebase-realtime-database

我正在构建一个数据库管理应用程序。我的数据库结构是: - Under the Customer object I have added children having Arraylist Value. index zero holds name, index 1,2 and 3 holds unique id's,我对如何读取这些数据并将其放入自定义listView感到困惑。我的代码是` 公共类MainActivity扩展了AppCompatActivity {

DatabaseReference details = FirebaseDatabase.getInstance().getReference();

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

    details.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
           GenericTypeIndicator<ArrayList<String>> t = new GenericTypeIndicator<ArrayList<String>>() {};
           ArrayList<String> yourStringArray = dataSnapshot.getValue(t);

        }

        @Override
        public void onCancelled(DatabaseError databaseError) {

        }
    });
}`

。应用程序一启动就会崩溃。请帮忙!!

0 个答案:

没有答案