import android.app.Activity;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class MainActivity extends Activity implements View.OnClickListener {
Button bshow,badd,bdel,bup;
Intent ii;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
bshow=(Button)findViewById(R.id.bshow);
badd=(Button)findViewById(R.id.badd);
bdel=(Button)findViewById(R.id.bdel);
bup=(Button)findViewById(R.id.bup);
bshow.setOnClickListener(this);
badd.setOnClickListener(this);
bdel.setOnClickListener(this);
bup.setOnClickListener(this);
}
@Override
public void onClick(View v) {
Button bb=(Button)v;
String text=bb.getText().toString();
if(text.equals("Show"))
{
ii=new Intent(getApplicationContext(),ShowActivity.class);
startActivity(ii);
}
if(text.equals("Add New"))
{
ii=new Intent(getApplicationContext(),AddActivity.class);
startActivity(ii);
}
if(text.equals("Delete"))
{
ii=new Intent(getApplicationContext(),DeleteActivity.class);
startActivity(ii);
}
if(text.equals("Update"))
{
ii=new Intent(getApplicationContext(),UpdateActivity.class);
startActivity(ii);
}
}
}
Add Activity
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class AddActivity extends AppCompatActivity {
Button baddnew;
EditText et1,et2;
String dbpath="/data/data/com.example.swapnil.dbapp/databases/";
static String dbname= "tempdb.db";
SQLiteDatabase db=null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add);
baddnew=(Button) findViewById(R.id.baddnew);
// bcancel=(Button)findViewById(R.id.bcancel);
// eid=(EditText)findViewById(R.id.eid);
et1=(EditText)findViewById(R.id.et1);
et2=(EditText)findViewById(R.id.et2);
baddnew.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// int id=Integer.parseInt(eid.getText().toString());
String name=et1.getText().toString();
int price=Integer.parseInt(et2.getText().toString());
String mydb=dbpath+dbname;
db=SQLiteDatabase.openDatabase(mydb,null,SQLiteDatabase.OPEN_READWRITE);
db.execSQL("insert into myshop values('"+name+"',"+price+")");
db.close();
Toast.makeText(getApplicationContext(),"New Record inserted sucessfully",Toast.LENGTH_LONG).show();
Intent ii=new Intent(getApplicationContext(),MainActivity.class);
startActivity(ii);
}
});
}
}
Delete
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class DeleteActivity extends AppCompatActivity {
Button bdelete;
EditText et1del;
String dbpath="/data/data/com.example.swapnil.dbapp/databases/";
static String dbname="tempdb.db";
SQLiteDatabase db=null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_delete);
// bdel=(Button)findViewById(R.id.bdelete);
bdelete=(Button)findViewById(R.id.bdelete);
et1del=(EditText)findViewById(R.id.et1del);
bdelete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String mydb=dbpath+dbname;
String name=(et1del.getText().toString());
db=SQLiteDatabase.openDatabase(mydb,null,SQLiteDatabase.OPEN_READWRITE);
Cursor cur=db.rawQuery("select price from myshop where name='"+name.toString()+"'",null);
if(cur.getCount()>0) {
db.execSQL("delete from myshop where name='"+name.toString()+"'");
Toast.makeText(getApplicationContext(),"Data Deleted Sucessfully",Toast.LENGTH_LONG).show();
Intent ii=new Intent(getApplicationContext(),MainActivity.class);
startActivity(ii);
}
else{
Toast.makeText(getApplicationContext(),"Not Found",Toast.LENGTH_LONG).show();
Intent ii=new Intent(getApplicationContext(),MainActivity.class);
startActivity(ii);
}
}
});
}
}
Show
import android.app.Activity;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class ShowActivity extends Activity {
String dbpath="/data/data/com.example.swapnil.dbapp/databases/";
static String dbname= "tempdb.db";
ListView lv;
SQLiteDatabase db=null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_show);
lv=(ListView)findViewById(R.id.lv);
dbhandle dbc=new dbhandle(getApplicationContext());
dbc.checkDatabase();
String mydb=dbpath+dbname;
db= SQLiteDatabase.openDatabase(mydb,null,SQLiteDatabase.OPEN_READONLY);
Cursor cur=db.rawQuery("select *from myshop",null);
String data[]=new String[cur.getCount()];
int i=0;
while(cur.moveToNext())
{
//or cur.getInt(cur.getColumnIndex("sid"));
String name=cur.getString(0);
int ag=cur.getInt(1);
data[i]= name+" , "+ag;
i++;
}
db.close();
ArrayAdapter ad=new ArrayAdapter(getApplicationContext(),android.R.layout.simple_list_item_1,data);
lv.setAdapter(ad);
}
}
update
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class UpdateActivity extends AppCompatActivity {
Button bupdate;
EditText et1up,et2up;
String dbpath="/data/data/com.example.xyz.dbapp/databases/";
String dbname="tempdb.db";
SQLiteDatabase db=null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_update);
bupdate=(Button)findViewById(R.id.bupdate);
et1up=(EditText)findViewById(R.id.et1up);
et2up=(EditText)findViewById(R.id.et2up);
bupdate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String mydb=dbpath+dbname;
// int id=Integer.parseInt(eupid.getText().toString());
String name=et1up.getText().toString();
int price= Integer.parseInt(et2up.getText().toString());
db= SQLiteDatabase.openDatabase(mydb,null,SQLiteDatabase.OPEN_READWRITE);
Cursor cur=db.rawQuery("select name from myshop where name='"+name+"'",null);
if(cur.getCount()>0) {
db.execSQL("update myshop set price ="+price+" where name='"+name+"'");
// db.execSQL("update emp set name='"+ename+"'where id="+id);
Toast.makeText(getApplicationContext(),"Data Updated Sucessfully",Toast.LENGTH_LONG).show();
Intent ii=new Intent(getApplicationContext(),MainActivity.class);
startActivity(ii);
}
else{
Toast.makeText(getApplicationContext(),"No Name Found",Toast.LENGTH_LONG).show();
Intent ii=new Intent(getApplicationContext(),MainActivity.class);
startActivity(ii);
}
db.close();
}
});
}
}
xml add
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="com.example.xyz.dbapp.AddActivity">
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="84dp"
android:text="Enter Name"
android:textSize="25dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="23dp"
android:layout_marginStart="23dp" />
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView2"
android:layout_alignStart="@+id/textView2"
android:layout_below="@+id/textView2"
android:layout_marginTop="68dp"
android:text="Enter Price"
android:textSize="25dp" />
android:id="@+id/et1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Name"
android:layout_alignBaseline="@+id/textView2"
android:layout_alignBottom="@+id/textView2"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
android:id="@+id/et2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Name"
android:layout_alignTop="@+id/textView3"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
Xml delete
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="com.example.swapnil.dbapp.DeleteActivity">
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter Name"
android:textSize="25dp"
tools:layout_editor_absoluteX="55dp"
tools:layout_editor_absoluteY="95dp"
android:layout_marginTop="119dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="11dp"
android:layout_marginStart="11dp" />
android:id="@+id/et1del"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
tools:layout_editor_absoluteX="150dp"
tools:layout_editor_absoluteY="81dp"
android:layout_alignBaseline="@+id/textView"
android:layout_alignBottom="@+id/textView"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
Xml main
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="com.example.swapnil.dbapp.MainActivity">
Xml show
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="com.example.swapnil.dbapp.ShowActivity">
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="8dp"
android:id="@+id/lv"/>
Xml update
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="com.example.swapnil.dbapp.UpdateActivity">
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="84dp"
android:text="Enter Name"
android:textSize="25dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="23dp"
android:layout_marginStart="23dp" />
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView2"
android:layout_alignStart="@+id/textView2"
android:layout_below="@+id/textView2"
android:layout_marginTop="68dp"
android:text="Enter Price"
android:textSize="25dp" />
android:id="@+id/et1up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:layout_alignBaseline="@+id/textView2"
android:layout_alignBottom="@+id/textView2"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
android:id="@+id/et2up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:layout_alignTop="@+id/textView3"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
android:id="@+id/bupdate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/et2up"
android:layout_marginTop="79dp"
android:layout_toEndOf="@+id/textView3"
android:layout_toRightOf="@+id/textView3"
android:text="Update"
android:textSize="25dp"/>
Manifest
package="com.example.swapnil.dbapp">
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/AppTheme">
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class MainActivity extends Activity implements View.OnClickListener {
Button bshow,badd,bdel,bup;
Intent ii;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
bshow=(Button)findViewById(R.id.bshow);
badd=(Button)findViewById(R.id.badd);
bdel=(Button)findViewById(R.id.bdel);
bup=(Button)findViewById(R.id.bup);
bshow.setOnClickListener(this);
badd.setOnClickListener(this);
bdel.setOnClickListener(this);
bup.setOnClickListener(this);
}
@Override
public void onClick(View v) {
Button bb=(Button)v;
String text=bb.getText().toString();
if(text.equals("Show"))
{
ii=new Intent(getApplicationContext(),ShowActivity.class);
startActivity(ii);
}
if(text.equals("Add New"))
{
ii=new Intent(getApplicationContext(),AddActivity.class);
startActivity(ii);
}
if(text.equals("Delete"))
{
ii=new Intent(getApplicationContext(),DeleteActivity.class);
startActivity(ii);
}
if(text.equals("Update"))
{
ii=new Intent(getApplicationContext(),UpdateActivity.class);
startActivity(ii);
}
}
}
Add Activity
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class AddActivity extends AppCompatActivity {
Button baddnew;
EditText et1,et2;
String dbpath="/data/data/com.example.swapnil.dbapp/databases/";
static String dbname= "tempdb.db";
SQLiteDatabase db=null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add);
baddnew=(Button) findViewById(R.id.baddnew);
// bcancel=(Button)findViewById(R.id.bcancel);
// eid=(EditText)findViewById(R.id.eid);
et1=(EditText)findViewById(R.id.et1);
et2=(EditText)findViewById(R.id.et2);
baddnew.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// int id=Integer.parseInt(eid.getText().toString());
String name=et1.getText().toString();
int price=Integer.parseInt(et2.getText().toString());
String mydb=dbpath+dbname;
db=SQLiteDatabase.openDatabase(mydb,null,SQLiteDatabase.OPEN_READWRITE);
db.execSQL("insert into myshop values('"+name+"',"+price+")");
db.close();
Toast.makeText(getApplicationContext(),"New Record inserted sucessfully",Toast.LENGTH_LONG).show();
Intent ii=new Intent(getApplicationContext(),MainActivity.class);
startActivity(ii);
}
});
}
}
Delete
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class DeleteActivity extends AppCompatActivity {
Button bdelete;
EditText et1del;
String dbpath="/data/data/com.example.swapnil.dbapp/databases/";
static String dbname="tempdb.db";
SQLiteDatabase db=null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_delete);
// bdel=(Button)findViewById(R.id.bdelete);
bdelete=(Button)findViewById(R.id.bdelete);
et1del=(EditText)findViewById(R.id.et1del);
bdelete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String mydb=dbpath+dbname;
String name=(et1del.getText().toString());
db=SQLiteDatabase.openDatabase(mydb,null,SQLiteDatabase.OPEN_READWRITE);
Cursor cur=db.rawQuery("select price from myshop where name='"+name.toString()+"'",null);
if(cur.getCount()>0) {
db.execSQL("delete from myshop where name='"+name.toString()+"'");
Toast.makeText(getApplicationContext(),"Data Deleted Sucessfully",Toast.LENGTH_LONG).show();
Intent ii=new Intent(getApplicationContext(),MainActivity.class);
startActivity(ii);
}
else{
Toast.makeText(getApplicationContext(),"Not Found",Toast.LENGTH_LONG).show();
Intent ii=new Intent(getApplicationContext(),MainActivity.class);
startActivity(ii);
}
}
});
}
}
Show
import android.app.Activity;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class ShowActivity extends Activity {
String dbpath="/data/data/com.example.swapnil.dbapp/databases/";
static String dbname= "tempdb.db";
ListView lv;
SQLiteDatabase db=null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_show);
lv=(ListView)findViewById(R.id.lv);
dbhandle dbc=new dbhandle(getApplicationContext());
dbc.checkDatabase();
String mydb=dbpath+dbname;
db= SQLiteDatabase.openDatabase(mydb,null,SQLiteDatabase.OPEN_READONLY);
Cursor cur=db.rawQuery("select *from myshop",null);
String data[]=new String[cur.getCount()];
int i=0;
while(cur.moveToNext())
{
//or cur.getInt(cur.getColumnIndex("sid"));
String name=cur.getString(0);
int ag=cur.getInt(1);
data[i]= name+" , "+ag;
i++;
}
db.close();
ArrayAdapter
lv.setAdapter(ad);
}
}
update
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class UpdateActivity extends AppCompatActivity {
Button bupdate;
EditText et1up,et2up;
String dbpath="/data/data/com.example.xyz.dbapp/databases/";
String dbname="tempdb.db";
SQLiteDatabase db=null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_update);
bupdate=(Button)findViewById(R.id.bupdate);
et1up=(EditText)findViewById(R.id.et1up);
et2up=(EditText)findViewById(R.id.et2up);
bupdate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String mydb=dbpath+dbname;
// int id=Integer.parseInt(eupid.getText().toString());
String name=et1up.getText().toString();
int price= Integer.parseInt(et2up.getText().toString());
db= SQLiteDatabase.openDatabase(mydb,null,SQLiteDatabase.OPEN_READWRITE);
Cursor cur=db.rawQuery("select name from myshop where name='"+name+"'",null);
if(cur.getCount()>0) {
db.execSQL("update myshop set price ="+price+" where name='"+name+"'");
// db.execSQL("update emp set name='"+ename+"'where id="+id);
Toast.makeText(getApplicationContext(),"Data Updated Sucessfully",Toast.LENGTH_LONG).show();
Intent ii=new Intent(getApplicationContext(),MainActivity.class);
startActivity(ii);
}
else{
Toast.makeText(getApplicationContext(),"No Name Found",Toast.LENGTH_LONG).show();
Intent ii=new Intent(getApplicationContext(),MainActivity.class);
startActivity(ii);
}
db.close();
}
});
}
}
xml add
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="com.example.xyz.dbapp.AddActivity">
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="84dp"
android:text="Enter Name"
android:textSize="25dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="23dp"
android:layout_marginStart="23dp" />
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView2"
android:layout_alignStart="@+id/textView2"
android:layout_below="@+id/textView2"
android:layout_marginTop="68dp"
android:text="Enter Price"
android:textSize="25dp" />
android:id="@+id/et1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Name"
android:layout_alignBaseline="@+id/textView2"
android:layout_alignBottom="@+id/textView2"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
android:id="@+id/et2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Name"
android:layout_alignTop="@+id/textView3"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
Xml delete
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="com.example.swapnil.dbapp.DeleteActivity">
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter Name"
android:textSize="25dp"
tools:layout_editor_absoluteX="55dp"
tools:layout_editor_absoluteY="95dp"
android:layout_marginTop="119dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="11dp"
android:layout_marginStart="11dp" />
android:id="@+id/et1del"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
tools:layout_editor_absoluteX="150dp"
tools:layout_editor_absoluteY="81dp"
android:layout_alignBaseline="@+id/textView"
android:layout_alignBottom="@+id/textView"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
Xml main
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="com.example.swapnil.dbapp.MainActivity">
Xml show
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="com.example.swapnil.dbapp.ShowActivity">
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="8dp"
android:id="@+id/lv"/>
Xml update
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="com.example.swapnil.dbapp.UpdateActivity">
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="84dp"
android:text="Enter Name"
android:textSize="25dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="23dp"
android:layout_marginStart="23dp" />
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView2"
android:layout_alignStart="@+id/textView2"
android:layout_below="@+id/textView2"
android:layout_marginTop="68dp"
android:text="Enter Price"
android:textSize="25dp" />
android:id="@+id/et1up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:layout_alignBaseline="@+id/textView2"
android:layout_alignBottom="@+id/textView2"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
android:id="@+id/et2up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:layout_alignTop="@+id/textView3"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
android:id="@+id/bupdate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/et2up"
android:layout_marginTop="79dp"
android:layout_toEndOf="@+id/textView3"
android:layout_toRightOf="@+id/textView3"
android:text="Update"
android:textSize="25dp"/>
Manifest
package="com.example.swapnil.dbapp">
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/AppTheme">
Output :