• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

adding a snapshot Item to arraylist

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

I am trying to add an item from a snapshot to an array list, but am getting the following error:      

I am added data to a database on Firebase Database...

and Iam trying to write a function that will update an ArrayList everytime there is a change in the particular node in the database: this is what I have done:



the dataSnapshot prints out this line:



the error: add(com.google.android.gms.common.util.Strings)in ArrayList cannot be applied to (java.lang.String)

I am trying to add the value: "name" to the ArrayList<String> called names



and onCreate:



Please help me, how do I do this... I can't find a tutorial that is clear on how to add a value to the ArrayList
 
Ranch Hand
Posts: 83
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
show us how you declare your ArrayList and the import statements just in case
 
Ben van Jaarsveld
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


and in onCreate:



thanks
 
Adrian Grabowski
Ranch Hand
Posts: 83
2
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know what com.google.android.gms.common.util.Strings is but if you want an ArrayList of Strings you would declare it as:

ArrayList<String>
 
Ben van Jaarsveld
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks man.... simple grammar problem... (was thinking more than 1 string makes Strings) ha ha ha
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!