Pre Test Phase - Coding
Pre Test Phase - Coding
> android:layout_below="@id/edit_text_type"
<androidx.constraintlayout.widget.ConstraintLayout android:layout_marginTop="5dp"
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_marginStart="20dp"
xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_marginEnd="20dp"
xmlns:tools="http://schemas.android.com/tools" />
android:layout_width="match_parent"
android:layout_height="match_parent" <EditText
tools:context=".MainActivity"> android:id="@+id/edit_text_generation"
android:layout_width="match_parent"
<ScrollView android:layout_height="wrap_content"
android:layout_width="match_parent" android:hint="@string/generation"
android:layout_height="match_parent"> android:inputType="text"
<RelativeLayout android:layout_below="@id/edit_text_category"
android:layout_width="fill_parent" android:layout_marginTop="5dp"
android:layout_height="wrap_content"> android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
<TextView />
android:id="@+id/tvtop"
android:layout_width="match_parent" <EditText
android:layout_height="wrap_content" android:id="@+id/edit_text_reaction"
android:layout_marginTop="10dp" android:layout_width="match_parent"
android:layout_marginStart="20dp" android:layout_height="wrap_content"
android:layout_marginEnd="20dp" android:hint="@string/reaction"
android:text="@string/medicine_info" android:inputType="text"
android:textSize="30sp"
android:gravity="center" /> android:layout_below="@id/edit_text_generation"
android:layout_marginTop="5dp"
<EditText android:layout_marginStart="20dp"
android:id="@+id/edit_text_id" android:layout_marginEnd="20dp"
android:layout_width="match_parent" />
android:layout_height="wrap_content"
android:hint="@string/id" <Button
android:inputType="number" android:id="@+id/btn_store_data"
android:layout_below="@id/tvtop" android:layout_width="60dp"
android:layout_marginTop="5dp" android:layout_height="40dp"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp" android:layout_below="@id/edit_text_reaction"
/> android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
<EditText android:text="@string/save"
android:id="@+id/edit_text_name" />
android:layout_width="match_parent"
android:layout_height="wrap_content" <Button
android:hint="@string/name" android:id="@+id/btn_view_data"
android:inputType="text" android:layout_width="60dp"
android:layout_below="@id/edit_text_id" android:layout_height="40dp"
android:layout_marginTop="5dp"
android:layout_marginStart="20dp" android:layout_below="@id/edit_text_reaction"
android:layout_marginEnd="20dp" android:layout_toEndOf="@id/btn_store_data"
/> android:layout_marginStart="10dp"
android:layout_marginTop="20dp"
<EditText android:text="@string/view"
android:id="@+id/edit_text_manufacturer" />
android:layout_width="match_parent"
android:layout_height="wrap_content" <Button
android:hint="@string/manufacturer" android:id="@+id/btn_update_data"
android:inputType="text" android:layout_width="80dp"
android:layout_below="@id/edit_text_name" android:layout_height="40dp"
android:layout_marginTop="5dp"
android:layout_marginStart="20dp" android:layout_below="@id/edit_text_reaction"
android:layout_marginEnd="20dp" android:layout_toEndOf="@id/btn_view_data"
/> android:layout_marginStart="10dp"
android:layout_marginTop="20dp"
<EditText android:text="@string/update"
android:id="@+id/edit_text_price" />
android:layout_width="match_parent"
android:layout_height="wrap_content" <Button
android:hint="@string/price" android:id="@+id/btn_delete_data"
android:inputType="number" android:layout_width="80dp"
android:layout_height="40dp"
android:layout_below="@id/edit_text_manufacturer"
android:layout_marginTop="5dp" android:layout_below="@id/edit_text_reaction"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp" android:layout_toEndOf="@id/btn_update_data"
/> android:layout_marginStart="10dp"
android:layout_marginTop="20dp"
<EditText android:layout_marginEnd="20dp"
android:id="@+id/edit_text_disease" android:text="@string/delete"
android:layout_width="match_parent" />
android:layout_height="wrap_content"
android:hint="@string/disease"
android:inputType="text" </RelativeLayout>
android:layout_below="@id/edit_text_price"
android:layout_marginTop="5dp" </ScrollView>
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp" </androidx.constraintlayout.widget.ConstraintLayout>
/>
<EditText
android:id="@+id/edit_text_type"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/type"
android:inputType="text"
android:layout_below="@id/edit_text_disease"
android:layout_marginTop="5dp"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
/>
<TextView
android:id="@+id/edit_text_category"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/category"
android:textSize="25sp"
package com.example.abcpharmacy; }
}
@Override
protected void onCreate(Bundle savedInstanceState) { showMessage("Data",buffer.toString());
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); }
db = new DatabaseHelper(this); });
etid = (EditText) findViewById(R.id.edit_text_id); public void showMessage (String title, String Message)
etname = (EditText) {
findViewById(R.id.edit_text_name);
etmanufacturer = (EditText) AlertDialog.Builder builder = new
findViewById(R.id.edit_text_manufacturer); AlertDialog.Builder(this);
etprice = (EditText) builder.setCancelable(true);
findViewById(R.id.edit_text_price); builder.setTitle(title);
etdisease = (EditText) builder.setMessage(Message);
findViewById(R.id.edit_text_disease); builder.show();
ettype = (EditText)
findViewById(R.id.edit_text_type); }
etgeneration = (EditText)
findViewById(R.id.edit_text_generation);
etreaction = (EditText)
findViewById(R.id.edit_text_reaction); public void updateData() {
addData(); etmanufacturer.getText().toString(),
viewData(); etdisease.getText().toString(),
updateData(); etreaction.getText().toString(),
deleteData(); ettype.getText().toString(),
etgeneration.getText().toString());
}
if (isUpdated == true) {
@Override
public void onCreate(SQLiteDatabase db) {
@Override
public void onUpgrade(SQLiteDatabase db, int i, int i1)
{
SQLiteDatabase db = this.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put(Column_1,ID);
contentValues.put(Column_2,Name);
contentValues.put(Column_3,Manufacturer);
contentValues.put(Column_4,Price);
contentValues.put(Column_5,Disease);
contentValues.put(Column_6,Type);
contentValues.put(Column_7,Generation);
contentValues.put(Column_8,Reaction);
if (res == -1){
return false;
}else
return true;
SQLiteDatabase db = this.getWritableDatabase();
Cursor res = db.rawQuery("select * from " +
Table_Name,null);
return res;
SQLiteDatabase db = this.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put(Column_1,ID);
contentValues.put(Column_2,Name);
contentValues.put(Column_3,Manufacturer);
contentValues.put(Column_4,Price);
contentValues.put(Column_5,Disease);
contentValues.put(Column_6,Type);
contentValues.put(Column_7,Generation);
contentValues.put(Column_8,Reaction);
db.update(Table_Name,contentValues, "ID = ?",new
String[] { ID });
return true;
SQLiteDatabase db = this.getWritableDatabase();
return db.delete(Table_Name,"ID = ?",new String[] {
ID });