Part 19 - Simple SharedPreferences

 Java Part : 

package first.learn.sharedpreference;

import static first.learn.sharedpreference.Common.getBooleanFromPref;
import static first.learn.sharedpreference.Common.getStringFromPref;
import static first.learn.sharedpreference.Common.saveBooleanToPref;
import static first.learn.sharedpreference.Common.saveStringToPref;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {


public static final String NAME = "NAME" ;
public static final String ADDRESS = "ADDRESS" ;
public static final String AGE = "AGE" ;
public static final String MARITAL_STATUS = "MARITAL_STATUS" ;


private String name = "";
private String age = "";
private String address= "";
private boolean maritalStatus = false ;




EditText etAddress,
etAge,
etName;

CheckBox checkbox;
Button btnSave, btnShow;





Context mContext ;

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

mContext = this ;


etAddress = (EditText)findViewById(R.id.etAddress);
etAge = (EditText)findViewById(R.id.etAge);
etName = (EditText)findViewById(R.id.etName);
checkbox = (CheckBox) findViewById(R.id.checkbox);



btnSave = (Button) findViewById(R.id.btnSave);
btnShow = (Button) findViewById(R.id.btnShow);


btnSave.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {


if(!isEditTextHasText(etName)
|| !isEditTextHasText(etAge)
|| !isEditTextHasText(etAddress)){

Toast.makeText(MainActivity.this, "Please Fill All The Field", Toast.LENGTH_SHORT).show();
return;
}


name = etName.getText().toString();
age = etAge.getText().toString();
address = etAddress.getText().toString();

saveStringToPref(mContext, NAME,name );
saveStringToPref(mContext, ADDRESS,address );
saveStringToPref(mContext, AGE, age );



maritalStatus = checkbox.isChecked();
saveBooleanToPref(mContext, MARITAL_STATUS, maritalStatus );

Toast.makeText(mContext, "Saved SuccessFully", Toast.LENGTH_SHORT).show();


}
});


btnShow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

name = getStringFromPref( mContext, NAME , "Not Saved");
etName.setText(name);

address = getStringFromPref(mContext, ADDRESS, "No Address");
etAddress.setText(address);

age = getStringFromPref(mContext, AGE, "No Age");
etAge.setText(age);

maritalStatus = getBooleanFromPref ( mContext, MARITAL_STATUS, false);

checkbox.setChecked(maritalStatus);


Toast.makeText(mContext, "Alhamdulillah, Data Retrieve Successfully", Toast.LENGTH_SHORT).show();



}
});







}

boolean isEditTextHasText (EditText editText){

String s = editText.getText().toString();

if(TextUtils.isEmpty(s)){
return false ;
}else {
return true ;
}

}




}


xml Part : 

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical"
android:layout_margin="16dp">

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="name....."
android:id="@+id/etName"/>


<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="age....."
android:id="@+id/etAge"/>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="address....."
android:id="@+id/etAddress"/>

<CheckBox
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Marital Status"
android:id="@+id/checkbox"/>


<Button
android:layout_marginTop="15dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/btnSave"
android:text="Save"/>

<Button
android:layout_marginTop="15dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/btnShow"
android:text="Retrieve"/>


</LinearLayout>


Common Class : 


package first.learn.sharedpreference;

import android.content.Context;
import android.content.SharedPreferences;
import android.widget.Toast;

public class Common {


public static void saveStringToPref(Context mContext, String packageName, String value ){

SharedPreferences settings = mContext.getSharedPreferences("MyPref", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = settings.edit();

editor.putString(packageName, value);
editor.apply();

}


public static void saveBooleanToPref(Context mContext, String packageName, boolean value ){

SharedPreferences settings = mContext.getSharedPreferences("MyPref", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = settings.edit();

editor.putBoolean(packageName, value);
editor.apply();

}


public static String getStringFromPref(Context mContext, String packetName, String defaultValue){

String s = defaultValue ;

SharedPreferences settings = mContext.getSharedPreferences("MyPref", Context.MODE_PRIVATE);


s = settings.getString(packetName, defaultValue);

return s ;


}

public static boolean getBooleanFromPref (Context mContext, String packageName, boolean value){

SharedPreferences settings = mContext.getSharedPreferences("MyPref", Context.MODE_PRIVATE);


boolean b = settings.getBoolean(packageName, value);

return b ;

}




}





Part 18 - Pass data to next Activity - method 7 and 8

 java part one : 

package first.learn.datapassingtwo;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.google.gson.Gson;

import first.learn.datapassingtwo.Person.PersonModel;

public class MainActivity extends AppCompatActivity {


public static String SIMPLE_STRING = null;
public static int SIMPLE_INT = -0;

EditText etOne, etTwo ,etThree,
etFour, etSix,
etFive;
Button btnSimpleInt,
btnSimpleString;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

etOne = (EditText) findViewById(R.id.etOne);
etTwo = (EditText) findViewById(R.id.etTwo);

btnSimpleInt = (Button)findViewById(R.id.btnSimpleInt);
btnSimpleString = (Button)findViewById(R.id.btnSimpleString);

etThree = (EditText)findViewById(R.id.etThree);
etFour = (EditText)findViewById(R.id.etFour);

etSix= (EditText)findViewById(R.id.etSix);
etFive= (EditText)findViewById(R.id.etFive);


btnSimpleString.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

String name = etOne.getText().toString();

if(TextUtils.isEmpty(name)){
etOne.setError("Empty");
return;
}

etOne.setError(null);



Intent intent = new Intent(Intent.ACTION_VIEW);
Uri data = Uri.parse("####://"+name);
intent.setData(data);
startActivity(intent);





}
});




btnSimpleInt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

String s = etTwo.getText().toString();
if(TextUtils.isEmpty(s)){
etTwo.setError("Empty");
return;
}

etTwo.setError(null);


Intent intent = new Intent(Intent.ACTION_VIEW);
Uri data = Uri.parse("#####://myhost/"+s);
intent.setData(data);
startActivity(intent);


}
});

}





}


xml part one : 


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical"
android:layout_margin="16dp">


<EditText
android:hint="only by Scheme......"
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/etOne"/>

<EditText
android:visibility="gone"
android:hint="age....."
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/etThree"/>


<EditText
android:visibility="gone"
android:hint="address....."
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/etFive"/>


<EditText
android:visibility="gone"
android:hint="MobileNumber.....(optional)"
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/etSix"/>

<Button
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/btnSimpleString"
android:text="Data passing with Manifest Scheme"/>


<EditText
android:hint="Scheme and Host ....."
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/etTwo"
/>


<EditText
android:visibility="gone"
android:hint="Simple int ....."
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/etFour"
android:inputType="number"/>


<Button
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/btnSimpleInt"
android:text="Data Passing By Scheme And Host "/>









</LinearLayout>


java part two : 

package first.learn.datapassingtwo;

import androidx.appcompat.app.AppCompatActivity;

import android.net.Uri;
import android.os.Bundle;
import android.widget.TextView;

public class DataGettingByManifestOnlyScheme extends AppCompatActivity {


TextView tvShow ;

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

tvShow = (TextView) findViewById(R.id.tvShow);


if(getIntent()!=null){

if(getIntent().getData()!=null){

Uri data = getIntent().getData();
String host = data.getHost();

System.out.println("Only Scheme Host : "+ host);

tvShow.setText(host);

}

}


}
}


xml part two : 

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".DataGettingByManifestOnlyScheme"
android:orientation="vertical">


<TextView
android:hint="data....."
android:layout_marginTop="25dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/purple_700"
android:textSize="25dp"
android:id="@+id/tvShow"/>




</LinearLayout>


java part three : 

package first.learn.datapassingtwo;

import androidx.appcompat.app.AppCompatActivity;

import android.net.Uri;
import android.os.Bundle;
import android.widget.TextView;

public class DataGettingBySchemeAndHost extends AppCompatActivity {


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


tvShow = (TextView) findViewById(R.id.tvShow);

if(getIntent()!=null){

if(getIntent().getData()!=null){

Uri data = getIntent().getData();
String myString = data.getLastPathSegment();

System.out.println("Scheme and Host : "+ myString);

tvShow.setText(myString);

}

}



}
}


xml part three : 

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".DataGettingBySchemeAndHost"
android:orientation="vertical">


<TextView
android:layout_marginTop="30dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/purple_700"
android:textSize="25dp"
android:id="@+id/tvShow"/>



</LinearLayout>


Manifest : 

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.DataPassingTwo"
tools:targetApi="31">

<activity
android:name=".DataGettingBySchemeAndHost"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data android:scheme="#####"
android:host="myhost"/>
</intent-filter>

</activity>

<activity
android:name=".DataGettingByManifestOnlyScheme"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data android:scheme="####" />
</intent-filter>
</activity>
<activity
android:name=".DataGettingActivity"
android:exported="false" />
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>


</application>

</manifest>






part 17 : Data Passing - Model Class - source code

 Java Part One : 

package first.learn.datapassingtwo;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.google.gson.Gson;

import first.learn.datapassingtwo.Person.PersonModel;

public class MainActivity extends AppCompatActivity {


public static String SIMPLE_STRING = null;
public static int SIMPLE_INT = -0;

EditText etOne, etTwo ,etThree,
etFour, etSix,
etFive;
Button btnSimpleInt,
btnSimpleString;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

etOne = (EditText) findViewById(R.id.etOne);
etTwo = (EditText) findViewById(R.id.etTwo);

btnSimpleInt = (Button)findViewById(R.id.btnSimpleInt);
btnSimpleString = (Button)findViewById(R.id.btnSimpleString);

etThree = (EditText)findViewById(R.id.etThree);
etFour = (EditText)findViewById(R.id.etFour);

etSix= (EditText)findViewById(R.id.etSix);
etFive= (EditText)findViewById(R.id.etFive);


btnSimpleString.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

String name = etOne.getText().toString();

if(TextUtils.isEmpty(name)){
etOne.setError("Empty");
return;
}



String age = etThree.getText().toString();
if(TextUtils.isEmpty(age)){
etThree.setError("Empty");
return;
}

String address = etFive.getText().toString();
if(TextUtils.isEmpty(age)){
etFive.setError("Empty");
return;
}


etOne.setError(null);
etThree.setError(null);
etFive.setError(null);

String mobileNumber = "No mobile Number";

mobileNumber = etSix.getText().toString();

if(TextUtils.isEmpty(mobileNumber)){
mobileNumber = "No mobile Number";
}



PersonModel personModel = new PersonModel();
personModel.setName(name);
personModel.setAge(age);
personModel.setAddress(address);
personModel.setMobileNumber(mobileNumber);


String stringToPass = new Gson().toJson(personModel);

System.out.println("Json String : "+ stringToPass);


Intent intent = new Intent(MainActivity.this, DataGettingActivity.class);
intent.putExtra("OneModelData", stringToPass);
startActivity(intent);


}
});


btnSimpleInt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

String s = etTwo.getText().toString();
if(TextUtils.isEmpty(s)){
etTwo.setError("Empty");
return;
}

etTwo.setError(null);

String t = etFour.getText().toString();

int q = -0 ;

try {
q = Integer.parseInt(t);
} catch (NumberFormatException e) {
throw new RuntimeException(e);
}


int p = -0;

try {
p = Integer.parseInt(s);
} catch (NumberFormatException e) {
throw new RuntimeException(e);
}

if(p==-0||q==-0){
Toast.makeText(MainActivity.this, "Please Write Valid Number", Toast.LENGTH_SHORT).show();
return;
}

Intent intent = new Intent(MainActivity.this, DataGettingActivity.class);

Bundle bundle = new Bundle();
bundle.putInt("SimpleIntOne", p);
bundle.putInt("SimpleIntTwo", q);
intent.putExtras(bundle);
startActivity(intent);


}
});

}





}



xml Part One : 


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical"
android:layout_margin="16dp">


<EditText
android:hint="name....."
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/etOne"/>

<EditText
android:hint="age....."
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/etThree"/>


<EditText
android:hint="address....."
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/etFive"/>


<EditText
android:hint="MobileNumber.....(optional)"
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/etSix"/>

<Button
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/btnSimpleString"
android:text="Passing Model Data"/>


<EditText
android:hint="Simple int ....."
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/etTwo"
android:inputType="number"/>


<EditText
android:hint="Simple int ....."
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/etFour"
android:inputType="number"/>


<Button
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/btnSimpleInt"
android:text="Button Simple Static Integer"/>









</LinearLayout>


Java Part Two : 


package first.learn.datapassingtwo;

import static first.learn.datapassingtwo.MainActivity.SIMPLE_INT;
import static first.learn.datapassingtwo.MainActivity.SIMPLE_STRING;

import androidx.appcompat.app.AppCompatActivity;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;

import com.google.gson.Gson;

import first.learn.datapassingtwo.Person.PersonModel;

public class DataGettingActivity extends AppCompatActivity {


TextView tvShow;

private String private_simple_string = null;
private int private_int = -0;

@SuppressLint("SetTextI18n")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_data_getting);

tvShow = (TextView) findViewById(R.id.tvShow);

if(getIntent()!=null){

if(getIntent().getStringExtra("SimpleString")!=null){

String s = getIntent().getStringExtra("SimpleString");

tvShow.setText(s);

}

}



if(getIntent()!=null){

if(getIntent().getIntExtra("SimpleInt", -0)!=-0){

int p = getIntent().getIntExtra("SimpleInt", -25);
tvShow.setText(""+p);

}

}


if(SIMPLE_STRING!=null){

tvShow.setText(SIMPLE_STRING);
private_simple_string = SIMPLE_STRING;
System.out.println("Taken STATIC String first : " + SIMPLE_STRING);


SIMPLE_STRING = null;

tvShow.setText(private_simple_string );

System.out.println("Taken Private String : " + private_simple_string);
System.out.println("Taken Static String : " + SIMPLE_STRING);


Toast.makeText(this, "Found : "+private_simple_string, Toast.LENGTH_SHORT).show();


}


if(SIMPLE_INT!=-0){

private_int = SIMPLE_INT ;
System.out.println("Static Int First : "+ SIMPLE_INT);

SIMPLE_INT = -0 ;
tvShow.setText(""+private_int);
System.out.println("Static Int Second : "+ SIMPLE_INT);
System.out.println(" private Int : "+ private_int);

}


if(getIntent()!=null){

if(getIntent().getExtras()!=null){

Bundle bundle = getIntent().getExtras();

if(bundle!=null) {
String a = bundle.getString("bundleStringOne");
String b = bundle.getString("bundleStringTwo");
System.out.println("a : "+ a +" b : "+ b );

tvShow.setText(a + " -- "+b );

}
}
}

if(getIntent()!=null){

if(getIntent().getExtras()!=null){

Bundle bundle = getIntent().getExtras();

if(bundle!=null) {

int a = bundle.getInt("SimpleIntOne");
int b = bundle.getInt("SimpleIntTwo");

System.out.println("a : "+ a +" b : "+ b );

tvShow.setText(a + " -- "+b );

}
}
}




if(getIntent()!=null){

if(getIntent().getStringExtra("OneModelData")!=null){

String foundString = getIntent().getStringExtra("OneModelData");

System.out.println("Json String get : "+ foundString);


PersonModel personModel = new Gson().fromJson(foundString, PersonModel.class );

String name = personModel.getName();
String age = personModel.getAge();
String address = personModel.getAddress();
String phoneNumber = personModel.getMobileNumber();


tvShow.setText(
"Name : "+name
+ "\n\n" +"Age: "+ age
+ "\n\n"+ "Address: "+ address
+ "\n\n"+"MobileNumber: "+ phoneNumber
);




}
}




}



}


xml Part Two : 

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".DataGettingActivity"
android:orientation="vertical"
android:layout_margin="16dp">


<TextView
android:hint="Data....."
android:textSize="30dp"
android:textColor="@color/purple_700"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tvShow"
/>




</LinearLayout>


Java Part 3 : 


package first.learn.datapassingtwo.Person;

public class PersonModel {

String name, age, address, mobileNumber;

public PersonModel() {
}

public PersonModel(String name, String age, String address, String mobileNumber) {
this.name = name;
this.age = age;
this.address = address;
this.mobileNumber = mobileNumber;
}


public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getAge() {
return age;
}

public void setAge(String age) {
this.age = age;
}

public String getAddress() {
return address;
}

public void setAddress(String address) {
this.address = address;
}

public String getMobileNumber() {
return mobileNumber;
}

public void setMobileNumber(String mobileNumber) {
this.mobileNumber = mobileNumber;
}
}


Java Part Four : 

package first.learn.datapassingtwo.Person;

public class BusinessClass {

String customerName, customerAddress, phone, quantity, unitPrice, totalPrice;

public BusinessClass() {
}

public BusinessClass(String customerName, String customerAddress, String phone, String quantity, String unitPrice, String totalPrice) {
this.customerName = customerName;
this.customerAddress = customerAddress;
this.phone = phone;
this.quantity = quantity;
this.unitPrice = unitPrice;
this.totalPrice = totalPrice;
}

public String getCustomerName() {
return customerName;
}

public void setCustomerName(String customerName) {
this.customerName = customerName;
}

public String getCustomerAddress() {
return customerAddress;
}

public void setCustomerAddress(String customerAddress) {
this.customerAddress = customerAddress;
}

public String getPhone() {
return phone;
}

public void setPhone(String phone) {
this.phone = phone;
}

public String getQuantity() {
return quantity;
}

public void setQuantity(String quantity) {
this.quantity = quantity;
}

public String getUnitPrice() {
return unitPrice;
}

public void setUnitPrice(String unitPrice) {
this.unitPrice = unitPrice;
}

public String getTotalPrice() {
return totalPrice;
}

public void setTotalPrice(String totalPrice) {
this.totalPrice = totalPrice;
}
}



Dependecy : 


implementation 'com.google.code.gson:gson:2.10.1'