Hello World! Today i am going to show you how to use Google’s room persistence library to manage all SQLite Operation with in your app.
According to google
The Room persistence library provides an abstraction layer over SQLite to allow fluent database access while harnessing the full power of SQLite.
In this post I am Just going to Cover CURD Operations ex: CREATE/UPDATE/READ/DELETE.
First Let Understand why we should use these type of libraries.
It check sql queries for error while compling.
Its reduces a lot of code we needed to write for regular operation
Its return data based on our queries directly in objects or we can wrap these results in LiveData, Reactive Observables as well as Cursor.
Lets create a simple project using room persistence library. In this tutorial we are going to create an app in which we can
- create person
- delete person
- update person
And of course fetch list of all person in our database.
This is my build.gradle (App level)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation 'com.android.support:appcompat-v7:26.1.0' implementation 'com.android.support.constraint:constraint-layout:1.0.2' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.1' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' implementation 'com.android.support:recyclerview-v7:26.1.0' implementation 'com.android.support:design:26.1.0' // Room implementation 'android.arch.persistence.room:runtime:1.0.0' annotationProcessor 'android.arch.persistence.room:compiler:1.0.0' } |
There are 3 major components in Room:
Entity: Represents a table within the database.
I am going to create a class and annote it with @Entity. This class is also going to serves as our model.
To set table name other then ModelPerson : @Entity(tableName = “tbl_person”)
@PrimaryKey(autoGenerate = true)
This is used to auto generate id
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
@Entity public class ModelPerson { @PrimaryKey(autoGenerate = true) private int personID; private String name, email, age; @Embedded public Address address; @Ignore public int extraField; public ModelPerson(String name, String email, String age,Address address) { this.name = name; this.email = email; this.age = age; this.address = address; } public int getPersonID() { return personID; } public void setPersonID(int personID) { this.personID = personID; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getAge() { return age; } public void setAge(String age) { this.age = age; } public Address getAddress() { return address; } public void setAddress(Address address) { this.address = address; } public int getExtraField() { return extraField; } public void setExtraField(int extraField) { this.extraField = extraField; } } |
1 2 |
@Embedded public Address address; |
By Using @Embedded we can pass object and room will insert address fields in ModelPerson
Address.class
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
public class Address { public String state; public String city; public Address(String state, String city) { this.state = state; this.city = city; } public String getState() { return state; } public void setState(String state) { this.state = state; } public String getCity() { return city; } public void setCity(String city) { this.city = city; } } |
DAO: Contains the methods used for accessing the database.
We are going to use this class to perform database opeartion.
As we can see that we are using 4 Annotation like @Query, @Insert, @Update and @Delete
PersonDao.class
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
@Dao public interface PersonDao { @Query("SELECT * FROM ModelPerson") List getAllPerson(); @Insert long addPerson(ModelPerson person); @Insert long[] addPersonList(List person); @Update int updatePersonRecord(ModelPerson person); @Delete void delete(ModelPerson person); } |
Database: Contains the database holder and serves as the main access point for the underlying connection to your app’s persisted, relational data.
The class that’s annotated with @Database should satisfy the following conditions:
Be an abstract class that extends RoomDatabase.
Include the list of entities associated with the database within the annotation.
Contain an abstract method that has 0 arguments and returns the class that is annotated with @Dao
Lets create our database
PersonDb.class
Entities = array of all entites/ class annoted with @Entity
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
package com.androidfizz.db; import android.arch.persistence.room.Database; import android.arch.persistence.room.Room; import android.arch.persistence.room.RoomDatabase; import android.content.Context; import com.androidfizz.dao.PersonDao; import com.androidfizz.model.ModelPerson; /** * Created by Aklesh on 3/9/2018. */ @Database(entities = {ModelPerson.class,}, version = 1) public abstract class PersonDb extends RoomDatabase { private static final String DB_NAME = "personDB"; private static volatile PersonDb instance; public static PersonDb getInstance(Context context) { if (instance == null) { instance = Room.databaseBuilder(context, PersonDb.class, DB_NAME) .allowMainThreadQueries()//TO ALLOW DATABASE OPERATION ON MAIN THREAD .build(); } return instance; } public abstract PersonDao getPersonDao(); } |
Simple List To show inserted person name,email and age with option to delete and update
AdapterPerson.class
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
package com.androidfizz.adapter; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import com.androidfizz.androidcurdroompersistence.R; import com.androidfizz.model.ModelPerson; import java.util.List; public class AdapterPerson extends RecyclerView.Adapter { public static final int TYPE_DELETE = 1; public static final int TYPE_UPDATE = 2; private List personList; public AdapterPerson(List personList) { this.personList = personList; } @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { return new MyViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.single_person_row, parent, false)); } @Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { ModelPerson single = personList.get(position); MyViewHolder mHolder = (MyViewHolder) holder; mHolder.tvName.setText(single.getName()); mHolder.tvEmail.setText(single.getEmail()); mHolder.tvAge.setText(single.getAge()); mHolder.tvDelete.setOnClickListener(new OnCustomCLick(single, TYPE_DELETE)); mHolder.tvUpdate.setOnClickListener(new OnCustomCLick(single, TYPE_UPDATE)); } //RETURN 0 if List size is null. This prvent our app from crashing @Override public int getItemCount() { return personList != null ? personList.size() : 0; } public void setListItems(List mTempPersonList) { this.personList = mTempPersonList; notifyDataSetChanged(); } protected class MyViewHolder extends RecyclerView.ViewHolder { private TextView tvName, tvEmail, tvAge, tvUpdate,tvDelete; MyViewHolder(View itemView) { super(itemView); tvName = itemView.findViewById(R.id.tvName); tvEmail = itemView.findViewById(R.id.tvEmail); tvAge = itemView.findViewById(R.id.tvAge); tvUpdate = itemView.findViewById(R.id.tvUpdate); tvDelete = itemView.findViewById(R.id.tvDelete); } } private class OnCustomCLick implements View.OnClickListener { private ModelPerson single; private int type; OnCustomCLick(ModelPerson single, int type) { this.single = single; this.type = type; } @Override public void onClick(View view) { if (mListner != null) mListner.onClick(single, type); } } //LISTNERS FOR CLICK EVENT (DELETE) private OnClickListner mListner; public interface OnClickListner { void onClick(ModelPerson single, int type); } public void setOnCustomClickListner(OnClickListner mListner) { this.mListner = mListner; } } |
single_person_row.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="10dp"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_toLeftOf="@+id/tvDelete" android:layout_toStartOf="@+id/tvDelete" android:orientation="vertical"> <TextView android:id="@+id/tvName" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ellipsize="end" android:maxLines="1" android:text="vishnu singh" android:textColor="#7f8c8d" android:textStyle="bold" /> <TextView android:id="@+id/tvEmail" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="2dp" android:ellipsize="end" android:maxLines="1" android:text="email@gmail.com" android:textColor="#7f8c8d" /> <TextView android:id="@+id/tvAge" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Age : 22" android:textColor="#c0392b" android:textStyle="bold" /> <TextView android:id="@+id/tvUpdate" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:padding="6dp" android:background="#eee" android:text="@string/update_me" android:textAllCaps="true" /> </LinearLayout> <TextView android:padding="6dp" android:background="#eee" android:id="@+id/tvDelete" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_marginEnd="8dp" android:layout_marginStart="8dp" android:text="@string/delete" /> </RelativeLayout> |
This is going to be our main activty
MainActivity.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
package com.androidfizz.androidcurdroompersistence; import android.app.Dialog; import android.content.Context; import android.graphics.Canvas; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.support.v4.content.ContextCompat; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; import com.androidfizz.adapter.AdapterPerson; import com.androidfizz.dao.PersonDao; import com.androidfizz.db.PersonDb; import com.androidfizz.model.Address; import com.androidfizz.model.ModelPerson; import java.util.ArrayList; import java.util.List; public class MainActivity extends AppCompatActivity { private PersonDao mPersonDao; private AdapterPerson mAdapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = findViewById(R.id.mToolbar); setSupportActionBar(toolbar); mPersonDao = PersonDb.getInstance(this).getPersonDao(); RecyclerView mList = findViewById(R.id.mList); LinearLayoutManager mLayoutManager = new LinearLayoutManager(this); mList.setLayoutManager(mLayoutManager); mList.setHasFixedSize(true); mAdapter = new AdapterPerson(new ArrayList<ModelPerson>()); mList.setAdapter(mAdapter); mList.addItemDecoration(new SingleItemDecoration(this)); mAdapter.setOnCustomClickListner(new AdapterPerson.OnClickListner() { @Override public void onClick(ModelPerson person, int type) { onAction(person, type); } }); getAllPersons(); //PLEASE USE VIEWMODEL INSTEAD OF getAllPersons(); } private void onAction(ModelPerson person, int type) { switch (type) { case AdapterPerson.TYPE_UPDATE: UpdatePerson(person); break; case AdapterPerson.TYPE_DELETE: mPersonDao.delete(person); getAllPersons(); //PLEASE USE VIEWMODEL INSTEAD OF getAllPersons(); break; } } private void UpdatePerson(final ModelPerson person) { View view = LayoutInflater.from(this).inflate(R.layout.alert_add_person, null); final Dialog mDialog = Utils.addPersonDialog(this, view); mDialog.show(); view.findViewById(R.id.ivClose).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mDialog.dismiss(); } }); final EditText etName = view.findViewById(R.id.etName); final EditText etEmail = view.findViewById(R.id.etEmail); final EditText etAge = view.findViewById(R.id.etAge); etName.setText(person.getName()); etEmail.setText(person.getEmail()); etAge.setText(person.getAge()); final Button btnAdd = view.findViewById(R.id.btnAdd); btnAdd.setText(R.string.update); btnAdd.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { btnAdd.setEnabled(false); String name = etName.getText().toString().trim(); String email = etEmail.getText().toString().trim(); String age = etAge.getText().toString().trim(); Address add = new Address("indian", "delhi"); ModelPerson mPerson = new ModelPerson(name, email, age, add); mPerson.setPersonID(person.getPersonID()); boolean isSuccess = mPersonDao.updatePersonRecord(mPerson) > 0; if (isSuccess) { Toast.makeText(MainActivity.this, R.string.update_success, Toast.LENGTH_SHORT).show(); getAllPersons(); //PLEASE USE VIEWMODEL INSTEAD OF getAllPersons(); } else { Toast.makeText(MainActivity.this, R.string.operation_failed, Toast.LENGTH_SHORT).show(); } mDialog.dismiss(); btnAdd.setEnabled(true); } }); } @Override public boolean onPrepareOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_item, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.mAddPerson: View view = LayoutInflater.from(this).inflate(R.layout.alert_add_person, null); final Dialog mDialog = Utils.addPersonDialog(this, view); mDialog.show(); view.findViewById(R.id.ivClose).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mDialog.dismiss(); } }); final EditText etName = view.findViewById(R.id.etName); final EditText etEmail = view.findViewById(R.id.etEmail); final EditText etAge = view.findViewById(R.id.etAge); final Button btnAdd = view.findViewById(R.id.btnAdd); btnAdd.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { btnAdd.setEnabled(false); String name = etName.getText().toString().trim(); String email = etEmail.getText().toString().trim(); String age = etAge.getText().toString().trim(); //For asynchronous /*Observable.fromCallable(new Callable<Object>() { @Override public Object call() throws Exception { return mPersonDao.addPerson(new ModelPerson(etName.getText().toString().trim() , etEmail.getText().toString().trim() , etAge.getText().toString().trim())); } }).subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Consumer<Object>() { @Override public void accept(Object o) throws Exception { } });*/ Address add = new Address("india", "delhi"); boolean isSuccess = mPersonDao.addPerson(new ModelPerson(name, email, age, add)) > 0; if (isSuccess) { Toast.makeText(MainActivity.this, R.string.inserted_successfully, Toast.LENGTH_SHORT).show(); getAllPersons(); //PLEASE USE VIEWMODEL INSTEAD FOR getAllPersons(); } else Toast.makeText(MainActivity.this, R.string.operation_failed, Toast.LENGTH_SHORT).show(); mDialog.dismiss(); btnAdd.setEnabled(true); } }); break; } return super.onOptionsItemSelected(item); } private void getAllPersons() { List<ModelPerson> mTempPersonList = mPersonDao.getAllPerson(); mAdapter.setListItems(mTempPersonList); } private class SingleItemDecoration extends RecyclerView.ItemDecoration { private Drawable mDivider; private SingleItemDecoration(Context context) { mDivider = ContextCompat.getDrawable(context, R.drawable.line_divider); } @Override public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { super.onDraw(c, parent, state); int left = parent.getPaddingLeft(); int right = parent.getWidth() - parent.getPaddingRight(); int childCount = parent.getChildCount() - 1; for (int i = 0; i < childCount; i++) { View child = parent.getChildAt(i); RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams(); int top = child.getBottom() + params.bottomMargin; int bottom = top + mDivider.getIntrinsicHeight(); mDivider.setBounds(left, top, right, bottom); mDivider.draw(c); } } } } |
activity_main.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
<?xml version="1.0" encoding="utf-8"?> <LinearLayout android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.androidfizz.androidcurdroompersistence.MainActivity"> <android.support.v7.widget.Toolbar android:id="@+id/mToolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:elevation="3dp" /> <android.support.v7.widget.RecyclerView android:id="@+id/mList" android:layout_width="match_parent" android:layout_height="wrap_content" android:clipToPadding="false" android:paddingBottom="?actionBarSize" android:paddingLeft="10dp" android:paddingRight="10dp" /> </LinearLayout> |
alert_add_person.xml
Alert dialog layout to add/update person information.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:padding="10dp"> <ImageView android:id="@+id/ivClose" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="end" android:padding="5dp" android:src="@drawable/ic_cross_24dp" /> <android.support.design.widget.TextInputLayout android:id="@+id/tiName" android:layout_width="match_parent" android:layout_height="wrap_content"> <EditText android:imeOptions="actionNext" android:id="@+id/etName" android:inputType="textPersonName" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Name" /> </android.support.design.widget.TextInputLayout> <android.support.design.widget.TextInputLayout android:id="@+id/tiEmail" android:layout_width="match_parent" android:layout_height="wrap_content"> <EditText android:imeOptions="actionNext" android:id="@+id/etEmail" android:inputType="textEmailAddress" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/email" /> </android.support.design.widget.TextInputLayout> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <android.support.design.widget.TextInputLayout android:layout_marginRight="10dp" android:id="@+id/tiAge" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_toLeftOf="@+id/btnAdd" android:layout_marginEnd="10dp"> <EditText android:imeOptions="actionDone" android:id="@+id/etAge" android:inputType="number" android:digits="0123456789" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/age" /> </android.support.design.widget.TextInputLayout> <Button android:id="@+id/btnAdd" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingRight="50dp" android:paddingLeft="50dp" android:textStyle="bold" android:textColor="#006DF0" android:layout_alignParentRight="true" android:background="@color/c_bdc3c7" android:text="@string/add" /> </RelativeLayout> </LinearLayout> |
Utils.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
package com.androidfizz.androidcurdroompersistence; import android.app.Dialog; import android.content.Context; import android.support.v7.app.AlertDialog; import android.view.View; /** * Created by Aklesh on 3/9/2018. */ public class Utils { public static Dialog addPersonDialog(Context context, View view) { AlertDialog.Builder mBuilder = new AlertDialog.Builder(context); mBuilder.setView(view); Dialog mDialog = mBuilder.create(); return mDialog; } } |
I am using an image button in toolbar for showing add person dialog
menu_item.xml
1 2 3 4 5 6 7 8 9 |
<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <item android:id="@+id/mAddPerson" app:showAsAction="always" android:icon="@drawable/ic_add_person_24dp" android:title="@string/add" /> </menu> |
styles.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
<resources> <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/c_bdc3c7</item> <item name="toolbarStyle">@style/MyToolBarStyle</item> </style> <style name="NoActionBar" parent="AppTheme"> <item name="windowActionBar">false</item> <item name="windowNoTitle">true</item> </style> <color name="c_ecf0f1">#ecf0f1</color> <color name="white">#ffffff</color> <color name="black">#000000</color> <color name="c_black">#000000</color> <color name="c_34495e">#34495e</color> <color name="c_bdc3c7">#bdc3c7</color> <style name="MyToolBarStyle" parent="Widget.AppCompat.Toolbar"> <item name="android:background">@color/white</item> <item name="titleTextAppearance">@style/MyTitleTextAppearance</item> <!-- <item name="subtitleTextAppearance">@style/MySubTitleTextAppearance</item>--> </style> <style name="MyTitleTextAppearance" parent="TextAppearance.Widget.AppCompat.Toolbar.Title"> <item name="android:textColor">@color/c_34495e</item> <item name="android:textSize">18sp</item> </style> </resources> </style> |
strings.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<resources> <string name="app_name">Curd Using Room </string> <string name="add">add</string> <string name="age">age</string> <string name="email">Email</string> <string name="delete">Delete</string> <string name="update">Update</string> <string name="update_success">Updated successfully</string> <string name="operation_failed">Operation failed</string> <string name="inserted_successfully">Person data is inserted into database successfully</string> <string name="update_me">Update me</string> </resources> |
Drawable to creating divider line for RecyclerViewline_divider.xml
1 2 3 4 5 6 7 8 9 10 11 |
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <size android:width="1dp" android:height="1dp" /> <solid android:color="@color/c_34495e" /> </shape> |
AndroidManifest.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.androidfizz.androidcurdroompersistence"> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/NoActionBar"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> |