This week i fix some bugs and learn to input the data using firebase database
Input Text instead of Email
If the user input it without the email pattern (i.e. firstname.lastname@example.org) there will be a warning. This code will check whether the user input it with the correct pattern or not.
Open straight to the Home
This code will check whether the user is already do Login or not. If the user already Login and close the app, when the user open the app again it will go straight to the Home Activity instead of Login Activity.
Save Data using Firebase Database
This is the example that i tried, the table’s name is artist and the primary key is artistId.
This is the code how to save the data using Firebase Database.
mDatabaseReference = FirebaseDatabase.getInstance().getReference(“artists”); is to set the table that we want to input the data.
addArtist method is the method to input the data. getKey() is used to get a random String or key so it will be different with other key (unique), make it like Primary Key. Then .child() is used as the Primary Key, then setValue is to set the data in the Primary Key, in the data i set Primary Key as the ID of artist.
Youtube, Simplified Coding channel: