Skip to content
Coding Fanatic
  • Android Development
  • News and Reviews
  • Road2Pro
  • Tutorials
  • Services
  • About

Realest Code I Ever Wrote, 72 of 100 Days…

  • July 30, 2020July 31, 2020
  • by Richard Clarke

I learned how to write data to my Realtime Database

You can find a video of this at the bottom of the page and a link to the source code here.

I added a Realtime Database to the ListOfNames Firebase project in test mode. Afterwards I wrote a few goofy entries just to get my feet wet. Once everything was complete, I imported the DatabaseReference and FirebaseDatabse classes into my project.

Next, I instantiated a FirebaseDatabase object (database) and a DatabaseReference object (myRef). Using the FirebaseDatabase object, I could obtain a reference to the database and assign it a value. In this case, the reference was named (message) with a value of (I made this myself 🙂) click below

 

The process above allows for reading and overwriting data. I played around and changed the argument in the myRef.setValue() method without changing the reference. This made the app overwrite the previously saved value with a new one.

This means the Realtime Database first checks for the already existing reference and, if it exists, overwrites its value. Otherwise, it creates the reference and saves the new value.  While it’s less secure without authentication, it’s good for what I need at the moment. 

Next I will experiment with reading data from the database. After that, we can see about configuring it with a ListView.

Join the mailing list to see updates like this every week!
Coding Fanatic

Happy Happy Android Image credits to Hather on DeviantArt

Related

Firebase Flawless Victory! 71 of 100 Days of Code
Hit a Bump on a Log 73 of 100 Days of Code
Richard Clarke
Richard is currently a developer using Java and Android Studio to build custom applications for Android. Richard tutored in mathematics at Montgomery College, and worked in Information Technology before entering the Software Development industry as a Quality Engineer.
100daysofcode Android AndroidDev Firebase Firebase Console Google Java software Softwre Development

Related articles

Your New Favorite Stopwatch App!…
Two for Two BABY! 7…
…But the App is for…
Play Store Blues – 5…
Top 4 Tips for Android…
No Dice – 3 of…

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Join the mailing list!

This field is required.

Check your inbox or spam folder to confirm your subscription.

Follow me on social media!

  • GitHub
  • YouTube
  • X
  • Instagram
  • LinkedIn
My Tweets

Join the mailing list!

This field is required.

Check your inbox or spam folder to confirm your subscription.

Follow me on social media!

  • X
  • GitHub
  • LinkedIn
  • YouTube

Archives

Theme by Colorlib Powered by WordPress