Skip to content

Instantly share code, notes, and snippets.

View AndroidBullOfficial's full-sized avatar

Waqas Younis AndroidBullOfficial

View GitHub Profile
UploadResults.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//get EditText into the String format
final String StudentRollNo = RollNo.getText().toString();
final String StudentTotalMarks = TotalMarks.getText().toString();
String StudentObtainedMarks = ObtainedMarks.getText().toString();
public class MainActivity extends AppCompatActivity {
//Declare globally
TextView logout;
EditText RollNo,TotalMarks,ObtainedMarks;
TextView UploadResults,SeeMarksDetails;
FirebaseAuth mAuth;
FirebaseDatabase database;
DatabaseReference myRef;
@Override
protected void onStart()
{
super.onStart();
if (currentUser != null) //check if current user is logged in
{
sendUserToMainActivity();
}
}
mAuth.signInWithEmailAndPassword(email, password) //use Firebase method to signin
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>()
{
@Override
public void onComplete(@NonNull Task<AuthResult> task)
{
if (task.isSuccessful())
{
// Sign in success, update UI with the signed-in user's information
Toast.makeText(LoginActivity.this, "Login Successful!!!", Toast.LENGTH_SHORT).show();
//When the btn is clicked
CreateAccount.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//get EditText into the String format
final String FullName = fullName.getText().toString();
final String email = emailEdtText.getText().toString();
String password = passwordEdtText.getText().toString();
String repeatPassword = RepeatPasswordEdtText.getText().toString();
public class SignUp extends AppCompatActivity {
//Declare globally
TextView GoToSignIn, CreateAccount;
EditText fullName,emailEdtText,passwordEdtText,RepeatPasswordEdtText;
RadioButton radioMale,radioFeMale;
FirebaseAuth mAuth;
FirebaseDatabase database;
DatabaseReference myRef;
String gender="";
package com.arslan6015.loginwithgoogle;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
//Update a node in database
update = findViewById(R.id.update);
update.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
FirebaseDatabase database1 = FirebaseDatabase.getInstance();
DatabaseReference reference = database1.getReference().child("message").child("java").child("user");
reference.setValue("arslan khan")
//you can also attach listenr just to know whetehr it is successful or not
.addOnSuccessListener(new OnSuccessListener<Void>() {
//Delete Node data from database
button2 = findViewById(R.id.button2);
button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DatabaseReference dbNode = FirebaseDatabase.getInstance().getReference().getRoot().child("python").child("user");
dbNode.setValue(null);
//or you can delte the node with the following code also
DatabaseReference dbNodetwo = FirebaseDatabase.getInstance().getReference().getRoot()
.child("php").child("User");
//For recyclerView
implementation "androidx.recyclerview:recyclerview:1.1.0"
// For control over item selection of both touch and mouse driven selection
implementation "androidx.recyclerview:recyclerview-selection:1.1.0-rc01"