Blogger Tips and TricksLatest Tips And TricksBlogger Tricks

MOBILE APPLICATION DEVELOPMENT LAB(CS6611 and IT6611)

Lab manual features
*A complete Lab Manual with pdf,source code,Procedure,download project and download android apk file for all experiment.
*Step by step procedure to install and execute all the programs.
*Anna University Latest Sylabus.Common to CSE and IT department
*Easy to execute all the experiment simply download the project.
*Have a android executable(.apk) file.Download and Run in your android device.
*Step by step procedure is available with the manual.So that  easily Run the experiment without the help of other.

A complete Lab Manual with source code for all experiment.

One day  Workshop:
                                Workshop on Mobile application development  is available for colleges.Content for the workshop are as follows
                                *Recent trends in mobile application development 
                                *Introduction about mobile application development environment(Android).
                                *Life cycle of android .Working nature of android software.
                                *Step by step installation for android software.
                                *Execution of  all lab experiments.
            Contact:8344790950

LabManual cost details
                     LAB MANUAL DVD(Rs 1000)
                                              The labmanual with dvd it includes all experiment in pdf,software and installation procedure.The labmanul cost RS1000.The dvd will be reach you with in one or two days.
                    LAB MANUAL SOFT COPY(Rs 700)
                                              The softcopy of lab manual is availabe via email.It includes all experiment in pdf,installation procedure.The labmanual cost RS700.The email will reach you shortly after payment.

Payment method:
                                              The payment has  be made to the following bank account.After payment contact as we will send our lab manual.

contact details:
CELL:8344790950
EMAIL:hitechguil@gmail.com 

Bank Account Details:

BANK NAME :STATE BANK OF INDIA
ACCOUNT NO:20222847933
ACCOUNT HOLDER NAME:P GUILBERT RAJ
IFSC CODE:SBIN0010501



Lab manual screen shot:
1.Gui component font and color
2.Layout manager:

3.Calculator:

4.Basic graphical pimitives:

5.Database application:

6.Rss Feed:

7.Multithreading Application:

8.GPS LOCATION:

9.Sdcard data storage:

10.Alert application :

11.Alarm Clock:


Lab manual in android app:



Lab manual feedback:



Implement an application that creates an alert upon receiving a message in android

1)Open eclipse or android studio and select new android project
2)Give project name and select next
3) Choose the android version.Choose the lowest android version(Android 2.2) and select next
4) Enter the package name.package name must be two word seprated by comma and click finish
5)Go to package explorer in the left hand side.select our project.
6)Go to res folder and select layout.Double click the main.xml file.Add the code below
  <ScrollView  xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:scrollbars="vertical" >
<TableLayout         
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:shrinkColumns="*"  android:stretchColumns="*" android:background="#000000">
                 
                        <TableRow
                            android:layout_height="wrap_content"
                            android:layout_width="match_parent"
                            android:gravity="center_horizontal">
                           <TextView
      android:id="@+id/Title"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:layout_margin="5px"
      android:focusable="false"
      android:focusableInTouchMode="false"
      android:gravity="center_vertical|center_horizontal"
      android:text="QUIZ"
      android:textSize="25sp"
      android:textStyle="bold" />
                           <View
                android:layout_height="2px"
                android:layout_marginTop="5dip"
                android:layout_marginBottom="5dip"
                android:background="#DDFFDD"/>
                       </TableRow>
                        <TableRow
                            android:layout_height="wrap_content"
                            android:layout_width="match_parent"
                            android:gravity="center_horizontal">
                            <TextView
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:textSize="18sp" android:text="1.CAPTIAL OF INDIA"
android:layout_span="4"
                                android:padding="18dip"
                                android:textColor="#ffffff"/>
                       </TableRow>
                  
                        <TableRow
                            android:id="@+id/tableRow1"
                            android:layout_height="wrap_content"
                            android:layout_width="match_parent">
         <RadioGroup
            android:id="@+id/answer1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="0.4" >
            <RadioButton
                android:id="@+id/answer1A"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textColor="#ffffff"
                android:text="CHENNAI" />
            <RadioButton
                android:id="@+id/answer1B"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textColor="#ffffff"
                android:text="NEW DELHI" />
            <RadioButton
                android:id="@+id/answer1C"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textColor="#ffffff"
                android:text="MUMBAI" />
             <RadioButton
                android:id="@+id/answer1D"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textColor="#ffffff"
                android:text="HYDERBAD" />
        </RadioGroup>
                        </TableRow>
                      <TableRow
                            android:layout_height="wrap_content"
                            android:layout_width="match_parent"
                            android:gravity="center_horizontal">
                            <TextView
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:textSize="18sp"
                                android:text="2. CAPTIAL OF RUSSIA?"
                                android:layout_span="4"
                                  android:padding="18dip"
                                android:textColor="#ffffff"/>
                       </TableRow>
                     
                        <TableRow
                            android:id="@+id/tableRow2"
                            android:layout_height="wrap_content"
                            android:layout_width="match_parent">
                            <RadioGroup
            android:id="@+id/answer2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="0.4" >
            <RadioButton
                android:id="@+id/answer2A"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textColor="#ffffff"
                android:text="WARSAW    " />
            <RadioButton
                android:id="@+id/answer2B"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textColor="#ffffff"
                android:text="BERLIN" />
            <RadioButton
                android:id="@+id/answer2C"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textColor="#ffffff"
                android:text="MASCOW    " />
             <RadioButton
                android:id="@+id/answer2D"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textColor="#ffffff"
                android:text="CANEBRA    " />
        </RadioGroup>
                        </TableRow>
                         <TableRow
                            android:layout_height="wrap_content"
                            android:layout_width="match_parent"
                            android:gravity="center_horizontal">
                            <Button
                                android:id="@+id/submit"
                                android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                  android:gravity="center"
                                    android:text="Submit"
                                    />
                       </TableRow>                                                                       
      </TableLayout>      
</ScrollView>

7) Now select mainactivity.java file and type the following code.In my coding maniactivity name is Alert1Activity .
package alert1.quiz;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.RadioGroup;
import android.widget.Toast;
import android.view.View.OnClickListener;
import android.widget.RadioGroup.OnCheckedChangeListener;
public class Alert1Activity extends Activity {
    private Button btnSubmitQuiz;
    int score,ans1,ans2;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        RadioGroup b1=(RadioGroup)findViewById(R.id.answer1);
        b1.setOnCheckedChangeListener(new OnCheckedChangeListener() {
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                // TODO Auto-generated method stub
                switch(checkedId) {
                    case R.id.answer1A:
                                                      ans1 =1;
                    break;
                    case R.id.answer1B:
                                                      ans1 =2;                  
                    break;
                    case R.id.answer1C:
                                                      ans1 =3;
                    break;
                    case R.id.answer1D:
                                                      ans1=4;
                    break;
                }
            }
        });
         RadioGroup b2=(RadioGroup)findViewById(R.id.answer2);
         b2.setOnCheckedChangeListener(new OnCheckedChangeListener() {
             public void onCheckedChanged(RadioGroup group, int checkedId) {
                 // TODO Auto-generated method stub
                 switch(checkedId) {
                     case R.id.answer2A:
                                                       ans2 =1;
                     break;
                     case R.id.answer2B:
                                                       ans2 =2;
                   
                     break;
                     case R.id.answer2C:
                                                       ans2 =3;
                     break;
                     case R.id.answer2D:
                                                       ans2=4;
                     break;
                 }
             }
         });
         btnSubmitQuiz = (Button) findViewById(R.id.submit);
         btnSubmitQuiz.setOnClickListener(new OnClickListener() {
             public void onClick(View v) {
                 AlertDialog.Builder alertDialog = new AlertDialog.Builder(Alert1Activity.this);
                  // Setting Dialog Title
                  alertDialog.setTitle("SHOW RESULT");
                  // Setting Dialog Message
                  alertDialog.setMessage("Are you sure you want SUBMIT this?");
                  // Setting Icon to Dialog
                 // alertDialog.setIcon(R.drawable.tick);
                  // Setting Positive "Yes" Button
                  alertDialog.setPositiveButton("YES", new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog,int which) {
                          score =0;
                           // TODO Auto-generated method stub
                           if(ans1 == 2)
                                                             score++;
                           if(ans2 == 3)
                                                             score++;                                                                               
                           Toast.makeText(Alert1Activity.this, "Your score is:"+score+" out of 2.", Toast.LENGTH_LONG).show();
                         
                      }
                  });
                  // Setting Negative "NO" Button
                  alertDialog.setNegativeButton("NO", new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog, int which) {
                      // Write your code here to invoke NO event
                      Toast.makeText(getApplicationContext(), "You clicked  NO.CHECK YOUR ANSWER", Toast.LENGTH_SHORT).show();
                      dialog.cancel();
                      }
                  });
                  // Showing Alert Message
                  alertDialog.show();
             }
         });
       
    }
}

8)Now go to main.xml and right click .select run as option and select run configuration
9) Android output is present in the android emulator as shown in below.







  
  
  
      

Develop an application that makes use of RSS Feed

1)Open eclipse or android studio and select new android project
2)Give project name and select next
3) Choose the android version.Choose the lowest android version(Android 2.2) and select next
4) Enter the package name.package name must be two word seprated by comma and click finish
5)Go to package explorer in the left hand side.select our project.
6)Go to res folder and select layout.Double click the main.xml file.Add the code below
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="@+android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
7) Now select mainactivity.java file and type the following code.In my coding maniactivity name is RssFeedActivity.
package rss.feed;

//import android.app.Activity;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
import android.app.ListActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class RssfeedActivity extends ListActivity {
    List headlines;
    List links;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        headlines = new ArrayList();
        links = new ArrayList();
        try {
            URL url = new URL("http://feeds.pcworld.com/pcworld/latestnews");

            XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
            factory.setNamespaceAware(false);
            XmlPullParser xpp = factory.newPullParser();

                // We will get the XML from an input stream
            xpp.setInput(getInputStream(url), "UTF_8");

                /* We will parse the XML content looking for the "<title>" tag which appears inside the "<item>" tag.
                 * However, we should take in consideration that the rss feed name also is enclosed in a "<title>" tag.
                 * As we know, every feed begins with these lines: "<channel><title>Feed_Name</title>...."
                 * so we should skip the "<title>" tag which is a child of "<channel>" tag,
                 * and take in consideration only "<title>" tag which is a child of "<item>"
                 *
                 * In order to achieve this, we will make use of a boolean variable.
                 */
            boolean insideItem = false;

                // Returns the type of current event: START_TAG, END_TAG, etc..
            int eventType = xpp.getEventType();
            while (eventType != XmlPullParser.END_DOCUMENT) {
                if (eventType == XmlPullParser.START_TAG) {

                    if (xpp.getName().equalsIgnoreCase("item")) {
                        insideItem = true;
                    } else if (xpp.getName().equalsIgnoreCase("title")) {
                        if (insideItem)
                            headlines.add(xpp.nextText()); //extract the headline
                    } else if (xpp.getName().equalsIgnoreCase("link")) {
                        if (insideItem)
                            links.add(xpp.nextText()); //extract the link of article
                    }
                }else if(eventType==XmlPullParser.END_TAG && xpp.getName().equalsIgnoreCase("item")){
                    insideItem=false;
                }

                eventType = xpp.next(); //move to next element
            }

        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (XmlPullParserException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        // Binding data
        ArrayAdapter adapter = new ArrayAdapter(this,
                android.R.layout.simple_list_item_1, headlines);

        setListAdapter(adapter);
    }

    public InputStream getInputStream(URL url) {
       try {
           return url.openConnection().getInputStream();
       } catch (IOException e) {
           return null;
         }
    }
    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
       Uri uri = Uri.parse((String) links.get(position));
       Intent intent = new Intent(Intent.ACTION_VIEW, uri);
       startActivity(intent);
    }
}
8)Go to AndroidManifest.xml file and paste the following code before <appllication> tab
<uses-permission android:name="android.permission.INTERNET"/>
9)Now go to main.xml and right click .select run as option and select run configuration
10) Android output is present in the android emulator as shown in below.


Write a mobile application that creates alarm clock in android

1)Open eclipse or android studio and select new android project
2)Give project name and select next
3) Choose the android version.Choose the lowest android version(Android 2.2) and select next
4) Enter the package name.package name must be two word seprated by comma and click finish
5)Go to package explorer in the left hand side.select our project.
6)Go to res folder and select layout.Double click the main.xml file.Add the code below
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
   <TextView
      android:id="@+id/Title"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:layout_margin="5px"
      android:focusable="false"
      android:focusableInTouchMode="false"
      android:gravity="center_vertical|center_horizontal"
      android:text="ALARM CLOCK"
      android:textSize="20sp"
      android:textStyle="bold" />
    <Button
        android:id="@+id/startSetDialog"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Set Target Time"/>
    <TextView
        android:id="@+id/alarmprompt"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />
</LinearLayout>
7) Now select mainactivity.java file and type the following code.In my coding maniactivity name is AlarmActivity.
package alarm.android;

import java.util.Calendar;
import java.util.Calendar;

import android.app.Activity;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.app.TimePickerDialog;
import android.app.TimePickerDialog.OnTimeSetListener;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.TimePicker;


public class AlarmActivity extends Activity {
    TimePicker myTimePicker;
     Button buttonstartSetDialog;
     TextView textAlarmPrompt;
  
     TimePickerDialog timePickerDialog;
  
     final static int RQS_1 = 1;
  
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
          
            textAlarmPrompt = (TextView)findViewById(R.id.alarmprompt);
          
            buttonstartSetDialog = (Button)findViewById(R.id.startSetDialog);
            buttonstartSetDialog.setOnClickListener(new OnClickListener(){

       @Override
       public void onClick(View v) {
        textAlarmPrompt.setText("");
        openTimePickerDialog(false);
      
       }});

        }

   
     private void openTimePickerDialog(boolean is24r){
      Calendar calendar = Calendar.getInstance();
   
      timePickerDialog = new TimePickerDialog(
              AlarmActivity.this,
        onTimeSetListener,
        calendar.get(Calendar.HOUR_OF_DAY),
        calendar.get(Calendar.MINUTE),
        is24r);
      timePickerDialog.setTitle("Set Alarm Time");
          
      timePickerDialog.show();

     }
      
        OnTimeSetListener onTimeSetListener
        = new OnTimeSetListener(){

      @Override
      public void onTimeSet(TimePicker view, int hourOfDay, int minute) {

       Calendar calNow = Calendar.getInstance();
       Calendar calSet = (Calendar) calNow.clone();

       calSet.set(Calendar.HOUR_OF_DAY, hourOfDay);
       calSet.set(Calendar.MINUTE, minute);
       calSet.set(Calendar.SECOND, 0);
       calSet.set(Calendar.MILLISECOND, 0);
     
       if(calSet.compareTo(calNow) <= 0){
        //Today Set time passed, count to tomorrow
        calSet.add(Calendar.DATE, 1);
       }
     
       setAlarm(calSet);
      }};

     private void setAlarm(Calendar targetCal){

      textAlarmPrompt.setText(
        "\n\n***\n"
        + "Alarm is set@ " + targetCal.getTime() + "\n"
        + "***\n");
   
      Intent intent = new Intent(getBaseContext(), AlarmReceiver.class);
      PendingIntent pendingIntent = PendingIntent.getBroadcast(getBaseContext(), RQS_1, intent, 0);
      AlarmManager alarmManager = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
      alarmManager.set(AlarmManager.RTC_WAKEUP, targetCal.getTimeInMillis(), pendingIntent);
   
     }
}
8)Right Click package and select new class .Give a class name as AlarmReceiver.Open AlarmReceiver.java file and type the following code.
package alarm.android;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;

public class AlarmReceiver extends BroadcastReceiver {
    @Override
     public void onReceive(Context arg0, Intent arg1) {
      Toast.makeText(arg0, "Alarm received!", Toast.LENGTH_LONG).show();

     }
}

9)Now go to main.xml and right click .select run as option and select run configuration
10) Android output is present in the android emulator as shown in below.





Develop an application that makes use of database

1)Open eclipse or android studio and select new android project
2)Give project name and select next
3) Choose the android version.Choose the lowest android version(Android 2.2) and select next
4) Enter the package name.package name must be two word seprated by comma and click finish
5)Go to package explorer in the left hand side.select our project.
6)Go to res folder and select layout.Double click the main.xml file.Add the code below
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
             android:id="@+id/myLayout"
             android:stretchColumns="0"
             android:layout_width="fill_parent"
             android:layout_height="fill_parent">
        <TextView android:text="@string/title"
                  android:layout_x="110dp"
                  android:layout_y="10dp"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"/>
        <TextView android:text="@string/empid"
                  android:layout_x="30dp"
                  android:layout_y="50dp"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"/>
        <EditText android:id="@+id/editEmpid"
                  android:inputType="number"  
                  android:layout_x="150dp"
                  android:layout_y="50dp"
                  android:layout_width="150dp"
                  android:layout_height="40dp"/>
        <TextView android:text="@string/name"
                  android:layout_x="30dp"
                  android:layout_y="100dp"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"/>
        <EditText android:id="@+id/editName"  
                  android:inputType="text"  
                  android:layout_x="150dp"
                  android:layout_y="100dp"
                  android:layout_width="150dp"
                  android:layout_height="40dp"/>
        <TextView android:text="@string/salary"
                  android:layout_x="30dp"
                  android:layout_y="150dp"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"/>
        <EditText android:id="@+id/editsalary"  
                  android:inputType="number"  
                  android:layout_x="150dp"
                  android:layout_y="150dp"
                  android:layout_width="150dp"
                  android:layout_height="40dp"/>
        <Button      android:id="@+id/btnAdd"
                  android:text="@string/add"
                  android:layout_x="30dp"
                  android:layout_y="200dp"
                  android:layout_width="130dp"
                  android:layout_height="40dp"/>
        <Button      android:id="@+id/btnDelete"
                  android:text="@string/delete"
                  android:layout_x="160dp"
                  android:layout_y="200dp"
                  android:layout_width="130dp"
                  android:layout_height="40dp"/>n
        <Button   android:id="@+id/btnModify"
                  android:text="@string/modify"
                  android:layout_x="30dp"
                  android:layout_y="250dp"
                  android:layout_width="130dp"
                  android:layout_height="40dp"/>
        <Button   android:id="@+id/btnView"
                  android:text="@string/view"
                  android:layout_x="160dp"
                  android:layout_y="250dp"
                  android:layout_width="130dp"
                  android:layout_height="40dp"/>
        <Button   android:id="@+id/btnViewAll"
                  android:text="@string/view_all"
                  android:layout_x="85dp"
                  android:layout_y="300dp"
                  android:layout_width="150dp"
                  android:layout_height="40dp"/>      
</AbsoluteLayout>
7)Go to values folder and select string.xml file.Replace the code below
<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="app_name">Employee detail1</string>
    <string name="hello">Hello World, Employee detail Activity!</string>

    <string name="title">Employee Details</string>
    <string name="empid">Enter Employee ID: </string>
    <string name="name">Enter Name: </string>
    <string name="salary">Enter salary: </string>
    <string name="add">Add Employee</string>
    <string name="delete">Delete Employee</string>
    <string name="modify">Modify Employee</string>
    <string name="view">View Employee</string>
    <string name="view_all">View All Employee</string>

</resources>
8) Now select mainactivity.java file and type the following code.In my coding maniactivity name is EmployeedetailActivity.

package student.detail;
//import android.R;
import android.app.Activity;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class Studentdetail1Activity extends Activity implements OnClickListener {
    EditText editEmpid,editName,editsalary;
    Button btnAdd,btnDelete,btnModify,btnView,btnViewAll;
    SQLiteDatabase db;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        editEmpid=(EditText)findViewById(R.id.editEmpid);
        editName=(EditText)findViewById(R.id.editName);
        editsalary=(EditText)findViewById(R.id.editsalary);
        btnAdd=(Button)findViewById(R.id.btnAdd);
        btnDelete=(Button)findViewById(R.id.btnDelete);
        btnModify=(Button)findViewById(R.id.btnModify);
        btnView=(Button)findViewById(R.id.btnView);
        btnViewAll=(Button)findViewById(R.id.btnViewAll);
        btnAdd.setOnClickListener(this);
        btnDelete.setOnClickListener(this);
        btnModify.setOnClickListener(this);
        btnView.setOnClickListener(this);
        btnViewAll.setOnClickListener(this);
        db=openOrCreateDatabase("EmployeeDB", Context.MODE_PRIVATE, null);
        db.execSQL("CREATE TABLE IF NOT EXISTS employee(empid VARCHAR,name VARCHAR,salary VARCHAR);");
    }
    public void onClick(View view)
    {
        if(view==btnAdd)
        {
            if(editEmpid.getText().toString().trim().length()==0||
               editName.getText().toString().trim().length()==0||
               editsalary.getText().toString().trim().length()==0)
            {
                showMessage("Error", "Please enter all values");
                return;
            }
            db.execSQL("INSERT INTO employee VALUES('"+editEmpid.getText()+"','"+editName.getText()+
                       "','"+editsalary.getText()+"');");
            showMessage("Success", "Record added");
            clearText();
        }
        if(view==btnDelete)
        {
            if(editEmpid.getText().toString().trim().length()==0)
            {
                showMessage("Error", "Please enter Employee id");
                return;
            }
            Cursor c=db.rawQuery("SELECT * FROM employee WHERE empid='"+editEmpid.getText()+"'", null);
            if(c.moveToFirst())
            {
                db.execSQL("DELETE FROM employee WHERE empid='"+editEmpid.getText()+"'");
                showMessage("Success", "Record Deleted");
            }
            else
            {
                showMessage("Error", "Invalid Employee id");
            }
            clearText();
        }
        if(view==btnModify)
        {
            if(editEmpid.getText().toString().trim().length()==0)
            {
                showMessage("Error", "Please enter Employee id");
                return;
            }
            Cursor c=db.rawQuery("SELECT * FROM employee WHERE empid='"+editEmpid.getText()+"'", null);
            if(c.moveToFirst())
            {
                db.execSQL("UPDATE employee SET name='"+editName.getText()+"',salary='"+editsalary.getText()+
                        "' WHERE empid='"+editEmpid.getText()+"'");
                showMessage("Success", "Record Modified");
            }
            else
            {
                showMessage("Error", "Invalid Rollno");
            }
            clearText();
        }
        if(view==btnView)
        {
            if(editEmpid.getText().toString().trim().length()==0)
            {
                showMessage("Error", "Please enter Employee id");
                return;
            }
            Cursor c=db.rawQuery("SELECT * FROM employee WHERE empid='"+editEmpid.getText()+"'", null);
            if(c.moveToFirst())
            {
                editName.setText(c.getString(1));
                editsalary.setText(c.getString(2));
            }
            else
            {
                showMessage("Error", "Invalid Employee id");
                clearText();
            }
        }
        if(view==btnViewAll)
        {
            Cursor c=db.rawQuery("SELECT * FROM employee", null);
            if(c.getCount()==0)
            {
                showMessage("Error", "No records found");
                return;
            }
            StringBuffer buffer=new StringBuffer();
            while(c.moveToNext())
            {
                buffer.append("Employee id: "+c.getString(0)+"\n");
                buffer.append("Name: "+c.getString(1)+"\n");
                buffer.append("salary: "+c.getString(2)+"\n\n");
            }
            showMessage("Employee details Details", buffer.toString());
        }
     
    }
    public void showMessage(String title,String message)
    {
        Builder builder=new Builder(this);
        builder.setCancelable(true);
        builder.setTitle(title);
        builder.setMessage(message);
        builder.show();
    }
    public void clearText()
    {
        editEmpid.setText("");
        editName.setText("");
        editsalary.setText("");
        editEmpid.requestFocus();
    }
}
9)Now go to main.xml and right click .select run as option and select run configuration
10) Android output is present in the android emulator as shown in below.

Flag Counter