Read Call logs and Contacts from mobile & stored it on SQLite Database


Android Read Call logs and Contacts from mobile & stored it on SQLite Database
Hi,

Today I am going to explain how to access call log and contacts from mobile and stored it on SQLite Database.

For accessing Call logs and the Contacts from the device you have to set some permissions on the AndroidManifest.xml

<uses-permission android:name="android.permission.READ_PHONE_STATE" /><uses-permission android:name="android.permission.READ_CALL_LOG" /><uses-permission android:name="android.permission.WRITE_CALL_LOG" /><uses-permission android:name="android.permission.READ_CONTACTS" /><uses-permission android:name="android.permission.CALL_PHONE"/><uses-permission android:name="android.permission.GET_TASKS" /><uses-permission android:name="android.permission.WRITE_SETTINGS" />

Create a SQLite DB helper class which will create a data base table on the phone memory .

Following is the code for the Database helper class

import java.sql.SQLException;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
public class DBHelper extends SQLiteOpenHelper {
private Context myContext;
// Database Version
private static final int DATABASE_VERSION = 1;
//DB path
private static String DB_PATH = "/data/data/com.pdcapp.activity/databases/";
// Contacts table name
private static final String TABLE_Company = "callHistory";
public static SQLiteDatabase myDB;
public DBHelper(Context myContext) {
  super(myContext, DATABASE_NAME, null, 1);
  this.myContext = myContext;
}
public void onCreate(SQLiteDatabase db) {
  String TABLE_Company="CREATE TABLE blacklist" +
  " (_id INTEGER PRIMARY KEY AUTOINCREMENT," +
  "caller_name TEXT," +
  "caller_no TEXT)";
  db.execSQL(TABLE_Company);
}
public void onUpgrade(SQLiteDatabase db, int oldVersion,int newVersion) {
   db.execSQL("DROP TABLE IF EXISTS " + TABLE_Company);
   // Create tables again
   onCreate(db);
}
public void openDataBase() throws SQLException{
  //Open the database
  String myPath = DB_PATH + DATABASE_NAME;
  myDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READWRITE);

}
public void close() {
// NOTE: openHelper must now be a member of CallDataHelper;
// you currently have it as a local in your constructor   
   if (myDB != null) {
   myDB.close();
  }
 }
}


Now we create a Calllog_activity class on this class we create a object of a DBHelper class to create a Database.

Following is the code for the in which we show he call logs over the listview.


public class FromCalllog_activity extends Activity implements Block_Contats,OnClickListener {

   Context curr_obj;
   ListView list_blockedNO;
   List<Caller_model> list_calldata;;
   CallLog_adapters adapter;
   Cursor managedCursor;
   public Block_Contats objBlock_Contats;
   Vector<Integer> vCallLog;
   Button btm_add;
   private DBHelper dbconn;
   private SQLiteDatabase db

  @Override
  protected void onCreate(Bundle savedInstanceState) {
     // TODO Auto-generated method stub
     super.onCreate(savedInstanceState);
     setContentView(R.layout.calllog_activity);
     curr_obj = this;
     objBlock_Contats = this;
     dbconn = new DBHelper(this);
     db = dbconn.getWritableDatabase();
     initialized();
     list_calldata = getCallDetails();

     adapter = new CallLog_adapters(curr_obj, R.layout.calllog_row,
     list_calldata, objBlock_Contats);
     list_blockedNO.setAdapter(adapter);
     adapter.setNotifyOnChange(true);
}

  private void initialized() {
    // TODO Auto-generated method stub
     list_blockedNO = (ListView) findViewById(R.id.list_blockedNO);
     btm_add = (Button) findViewById(R.id.btm_add);
     btm_add.setOnClickListener(this);
}

    @SuppressWarnings("deprecation")
    private List<Caller_model> getCallDetails() {

      String strOrder = android.provider.CallLog.Calls.DATE + " DESC";
       @SuppressWarnings("rawtypes")
       List list_Data = new ArrayList<String>();
       managedCursor = managedQuery(CallLog.Calls.CONTENT_URI, null, null,null, strOrder);
       int name = managedCursor.getColumnIndex(CallLog.Calls.CACHED_NAME);
       int number = managedCursor.getColumnIndex(CallLog.Calls.NUMBER);
       int type = managedCursor.getColumnIndex(CallLog.Calls.TYPE);
       int date = managedCursor.getColumnIndex(CallLog.Calls.DATE);
       int duration = managedCursor.getColumnIndex(CallLog.Calls.DURATION);
       while (managedCursor.moveToNext()) {
          Caller_model data_model = new Caller_model();
          String caller_name = managedCursor.getString(name);
          String phNumber = managedCursor.getString(number);
          String callType = managedCursor.getString(type);
          String callDate = managedCursor.getString(date);
          Date callDayTime = new Date(Long.valueOf(callDate));
          String callDuration = managedCursor.getString(duration);
          String dir = null;
          int dircode = Integer.parseInt(callType);

            switch (dircode) {
              case CallLog.Calls.OUTGOING_TYPE:
                 dir = "OUTGOING";
              break;

              case CallLog.Calls.INCOMING_TYPE:
                dir = "INCOMING";
              break;

             case CallLog.Calls.MISSED_TYPE:
                dir = "MISSED";
             break;
             case 10:  //this case is for unknown no mostly on china handset
               dir = "UNKNOWN CASE";
             break;
            default:
            break;

         }

         String names;
          if (caller_name != null) {
              names = caller_name;
          } else {
           names = "Unknown";
         }
          data_model.setCaller_name(names);
          data_model.setCaller_no(phNumber);
          data_model.setCall_type(dir);
          data_model.setCall_date(callDayTime.toString());
          data_model.setCall_duration(callDuration);
          list_Data.add(data_model);

      }

          managedCursor.close();
          return list_Data;

 }

    @Override
    protected void onPause() {
          // TODO Auto-generated method stub
          super.onPause();
          managedCursor.close();
     }

    @Override
       protected void onDestroy() {
          // TODO Auto-generated method stub
         super.onDestroy();
        managedCursor.close();
 }

      @Override
       public void Block_Contats(Vector<Integer> v) {
          // TODO Auto-generated method stub
          vCallLog = v;
    }

     @Override
      public void onClick(View v) {
          // TODO Auto-generated method stub
            switch (v.getId()) {
               case R.id.btm_add:
                     if (vCallLog.size() > 0)
                      for (int i : vCallLog) {
                           db.execSQL("insert into blacklist"
                                + "(" + "caller_no,caller_name) " + "values('"
                                + list_calldata.get(i).getCaller_no() + "','"
                                + list_calldata.get(i).getCaller_name() + "')");
                            }
                            db.close();
                            this.finish();
                            break;

                       default:
                        break;
              }
         }
  }

On this activity I create a object on a DBHelper class which will stored the selected number on the database

Here I create a getter setter class which will set and get the caller infomation.

public class Caller_model {

      public String caller_name;
      public String caller_no;
      public String call_type;
      public String call_date;
      public String call_duration;
      public String getCaller_name() {
        return caller_name;
      }
      public void setCaller_name(String caller_name) {
          this.caller_name = caller_name;
      }
      public String getCaller_no() {
          return caller_no;
      }
      public void setCaller_no(String caller_no) {
          this.caller_no = caller_no;
      }
      public String getCall_type() {
        return call_type;
      }
      public void setCall_type(String call_type) {
        this.call_type = call_type;
      }
      public String getCall_date() {
        return call_date;
      }
      public void setCall_date(String call_date) {
         this.call_date = call_date;
      }
      public String getCall_duration() {
       return call_duration;
      }
      public void setCall_duration(String call_duration) {
          this.call_duration = call_duration;
      }
}

Now we create a adapter class which will show the data over the listview on android.

public class CallLog_adapters extends ArrayAdapter<Caller_model> {

        Context mContext;
        int resource;
        List<Caller_model> callLog_data;
        Vector<Integer> Check_pos = new Vector<Integer>();
        int size;
        public Block_Contats objBlock_Contats;

        public CallLog_adapters(Context mContext, int resource,
          List<Caller_model> callLog_data,Block_Contats objBlock_Contats) {
            super(mContext, resource, callLog_data);
            // TODO Auto-generated constructor stub
            this.mContext = mContext;
            this.resource = resource;
            this.callLog_data = callLog_data;
            this.objBlock_Contats = objBlock_Contats;
            size = callLog_data.size();
         }

        class ViewHolder {
          protected TextView txt_name;
          protected TextView txt_no;
          protected TextView txt_time;
          protected CheckBox []chk_no = new CheckBox[size];
          protected TextView txt_type;
      }

       @Override
       public View getView(final int position, View convertView, ViewGroup parent)         { 
          // TODO Auto-generated method stub
          final ViewHolder holder;
          LayoutInflater inflator = ((Activity) mContext).getLayoutInflater();
          convertView = inflator.inflate(R.layout.calllog_row, null);
           holder = new ViewHolder();
           holder.txt_name = (TextView) convertView
           .findViewById(R.id.txt_name);
           holder.txt_no = (TextView) convertView.findViewById(R.id.txt_no);
          holder.txt_time = (TextView) convertView
          .findViewById(R.id.txt_time);
          holder.chk_no[position] = (CheckBox)                  convertView.findViewById(R.id.chk_no);
         holder.txt_type = (TextView) convertView
         .findViewById(R.id.txt_type);
         convertView.setTag(holder);

         holder.chk_no[position]
         .setOnCheckedChangeListener(new OnCheckedChangeListener() {

           @Override
      public void onCheckedChanged(CompoundButton buttonView,
            boolean isChecked) {
           // TODO Auto-generated method stub
          if (isChecked == true) {
             if (!Check_pos.contains(position)) {
                 Check_pos.add(position);
                 objBlock_Contats.Block_Contats(Check_pos);
            }
          } else if (isChecked == false) {
              for(int i=0;i<Check_pos.size();i++){
                 if(Check_pos.elementAt(i)==position){
                      Check_pos.removeElementAt(i);
                         objBlock_Contats.Block_Contats(Check_pos);

                   }
                }
           }
        }
      });

        if (Check_pos.size() > 0) {
         if (Check_pos.contains(position)){
                holder.chk_no[position].setChecked(true);
         } else{
             holder.chk_no[position].setChecked(false);
       }
    }
         holder.txt_name.setText("Caller Name: "
         + callLog_data.get(position).getCaller_name().toString());
         holder.txt_no.setText("Caller Number: "
         + callLog_data.get(position).getCaller_no().toString());
         holder.txt_time.setText("Call duration: "
         + callLog_data.get(position).getCall_duration().toString()+" sec");
         holder.txt_type.setText("Call Type: "
         + callLog_data.get(position).getCall_type().toString());
         return convertView;
   }
    public interface Block_Contats{
         public void Block_Contats(Vector<Integer> v);
      }
  }

On this adapter I create a interface which will pass the selected call no to stored on data base table.

Following is the xml file for the callloger activity
<?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="match_parent"
android:orientation="vertical"
android:background="#F3F2F0" >

      <LinearLayout
          android:id="@+id/LL_footerButton"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentBottom="true"
          android:orientation="horizontal"
          android:padding="@dimen/ten_dp" >

        <Button
          android:id="@+id/btm_add"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:text="Add to blacklist"
          android:background="@drawable/button_email_drawable"/>
  </LinearLayout>

      <ListView
           android:id="@+id/list_blockedNO"
           android:layout_width="fill_parent"
           android:layout_height="wrap_content"
           android:layout_alignParentTop="true"
          android:layout_above="@+id/LL_footerButton"
         />

</RelativeLayout>

Follwing is the xml for creating a row for the callloger adapter
calllog_row.xml
<?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="match_parent"
android:orientation="vertical"
android:padding="@dimen/ten_dp" >

    <RelativeLayout
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:orientation="horizontal" >

      <LinearLayout
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:orientation="vertical"
       android:layout_alignParentLeft="true" >

     <TextView
         android:id="@+id/txt_name"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:text="+919967941419" />
      <TextView
         android:id="@+id/txt_no"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:text="+919967941419" />
      <TextView
           android:id="@+id/txt_time"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:text="12:12pm" />
        <TextView
           android:id="@+id/txt_type"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:text="Outgoing" />
       </LinearLayout>
       <CheckBox
         android:id="@+id/chk_no"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_alignParentRight="true"
         android:button="@drawable/check_box"/>
 </RelativeLayout>

</RelativeLayout>


Accessing Contacts from Device

Now I create a another activity to get the stored contacts from the mobile.
On this activity I show the contact name , contact no alogn with the caller image

public class Contact_activity extends Activity implements               Block_Contats,OnClickListener{

     Context curr_obj;
     ListView list_contact;
     List<Contact_model> list_contactdata;
     Contact_adapter adapter;
     Cursor cur;
     ContentResolver cr;
     Button btm_add;
     SimpleCursorAdapter mAdapter;
     MatrixCursor mMatrixCursor;
     private ProgressDialog progressDialog;
     public Block_Contats objBlock_Contats;
     Vector<Integer> getNo;
     private DBHelper dbconn;
     private SQLiteDatabase db;
     private EditText edt_search;
       @Override
      protected void onCreate(Bundle savedInstanceState) {
         // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fromcontact_activity);
        curr_obj = this;
        objBlock_Contats = this;
        dbconn = new DBHelper(this);
        db = dbconn.getWritableDatabase();
        initialized();
     }

     private void initialized() {
       // TODO Auto-generated method stub
       list_contact = (ListView) findViewById(R.id.list_contact);
       list_contact.setTextFilterEnabled(true);
       btm_add = (Button) findViewById(R.id.btm_add);
       btm_add.setOnClickListener(this);
       new ListViewContactsLoader().execute();
       edt_search = (EditText) findViewById(R.id.edt_search);
       edt_search.addTextChangedListener(new TextWatcher() {
      @Override
      public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) {
       // When user changed the Text
      FromContact_activity.this.adapter.getFilter().filter(cs);
       list_contact.setAdapter(adapter);
   }
     @Override
      public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
        int arg3) {
       // TODO Auto-generated method stub
    }
     @Override
    public void afterTextChanged(Editable arg0) {
        // TODO Auto-generated method stub
        adapter.notifyDataSetChanged();
     }
   });

}

   String contactName = null;
   String contactNumber = null;
   String image_uri = "";
   Bitmap bitmap = null;

   private String contactID;

   /** An AsyncTask class to retrieve and load listview with contacts */
   private class ListViewContactsLoader extends
    AsyncTask<Void, Void, List<Contact_model>> {

    @SuppressWarnings("unchecked")
    @Override
    protected List<Contact_model> doInBackground(Void... params) {
       // TODO Auto-generated method stub
   
      List list_Data = new ArrayList<String>();

     Cursor contact = getContentResolver().query(
     ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,
       null, null,
     ContactsContract.Contacts.DISPLAY_NAME + " ASC ");

    while (contact.moveToNext()) {
         Contact_model dataModel = new Contact_model();
         contactName = contact
         .getString(contact
         .getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
     dataModel.setcontact_name(contactName);
     contactNumber = contact
     .getString(contact
     .getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
      dataModel.setContact_no(contactNumber);
     image_uri =       contact.getString(contact.getColumnIndex(ContactsContract.CommonDataKinds.Phone.PHOTO_URI));
  if (image_uri != null) {
       System.out.println(Uri.parse(image_uri));
     try {
         bitmap = MediaStore.Images.Media           .getBitmap(FromContact_activity.this.getContentResolver(),
       Uri.parse(image_uri));
       dataModel.setBitmap(bitmap);
     } catch (Exception e) {
  }
}//if
  list_Data.add(dataModel);
}

return list_Data;
}

   @Override
    protected void onPostExecute(List<Contact_model> result) {
     // TODO Auto-generated method stub
     super.onPostExecute(result);
     progressDialog.dismiss();
     list_contactdata = result;
     adapter = new Contact_adapter(curr_obj, R.layout.contact_row,
     list_contactdata,objBlock_Contats);
     list_contact.setAdapter(adapter);
     adapter.setNotifyOnChange(true);
  }

  @Override
    protected void onPreExecute() {
     // TODO Auto-generated method stub
     super.onPreExecute();
     progressDialog = ProgressDialog.show(FromContact_activity.this,
     "Wait", "Loading contacts...");

   }

}

   @Override
   public void Block_Contats(Vector<Integer> v) {
    // TODO Auto-generated method stub
     getNo=v;
}

  @Override
  public void onClick(View v) {
   // TODO Auto-generated method stub
    switch (v.getId()) {
       case R.id.btm_add:
        if(getNo.size()>0)
        for(int i=0;i<getNo.size();i++ ){
            db.execSQL("insert into blacklist"
            + "(" + "caller_no,caller_name) " + "values('"
            + list_contactdata.get(getNo.get(i)).getContact_no() + "','"
            + list_contactdata.get(getNo.get(i)).getcontact_name() + "')");
       }
      db.close();
       this.finish();
      break;

     default:
      break
    }
   }

}
The OnClick event add the select contact on the same database table

Now the following code is the getter setter class for the contacts activity

   public class Contact_model {

       public String id;
       public String contact_name;
       public String contact_no;
       public String image_uri;
       public Bitmap bitmap;
       public String getId() {
          return id;
     }
    public void setId(String id) {
        this.id = id;
    }
    public Bitmap getBitmap() {
         return bitmap;
    }
      public void setBitmap(Bitmap bitmap) {
         this.bitmap = bitmap;
    }
    public String getcontact_name() {
        return contact_name;
      }
      public void setcontact_name(String contact_name) {
       this.contact_name = contact_name;
      }
     public String getContact_no() {
       return contact_no;
      }
    public void setContact_no(String contact_no) {
         this.contact_no = contact_no;
    }
    public String getImage_uri() {
        return image_uri
    }
    public void setImage_uri(String image_uri) {
      this.image_uri = image_uri;
   }
}

Here I create a ArrayAdater class which will display the contact name,number and caller photos if caller dosenot having photo then I set a default photo for the caller

public class Contact_adapter extends ArrayAdapter<Contact_model> implements  Filterable{

   // contact_row
    Context mContext;
    int resource;
    List<Contact_model> contact_data;
    Bitmap bb;
    int widht, height;
    int pos_val;
    int size;
    Vector<Integer> Check_pos = new Vector<Integer>();
    public Block_Contats objBlock_Contats;

    public Contact_adapter(Context mContext, int resource,
        List<Contact_model> contact_data,Block_Contats objBlock_Contats) {
        super(mContext, resource, contact_data);
        // TODO Auto-generated constructor stub
        this.mContext = mContext;
        this.resource = resource;
        this.contact_data = contact_data;
        this.objBlock_Contats = objBlock_Contats;
        size = contact_data.size();
        bb = new BitmapFactory().decodeResource(mContext.getResources(),
         R.drawable.icon_passenger);
       widht = bb.getWidth();
       height = bb.getHeight();
     }

   class ViewHolder {
      protected TextView txt_name;
      protected TextView txt_phone;
      protected TextView txt_emailType;
      protected CheckBox[] chk_contact = new CheckBox[size];
      protected TextView txt_emailContact;
      protected ImageView image_caller;
    }

   @Override
   public View getView(final int position, View convertView, ViewGroup parent) {
      // TODO Auto-generated method stub
      final ViewHolder holder;
      LayoutInflater inflator = ((Activity) mContext).getLayoutInflater();
      convertView = inflator.inflate(R.layout.contact_row, null);
      holder = new ViewHolder();
      holder.txt_name = (TextView) convertView
       .findViewById(R.id.txt_name);
      holder.txt_phone = (TextView) convertView
      .findViewById(R.id.txt_phone);

      holder.image_caller = (ImageView) convertView
         .findViewById(R.id.image_caller);
      convertView.setTag(holder);
      holder.chk_contact[position] = (CheckBox) convertView
      .findViewById(R.id.chk_contact);
    
     holder.chk_contact[position].setTag(position);

     holder.chk_contact[position]
    .setOnCheckedChangeListener(new OnCheckedChangeListener() {

    @Override
    public void onCheckedChanged(CompoundButton buttonView,
       boolean isChecked) {
       // TODO Auto-generated method stub
      if (isChecked == true) {
         if (!Check_pos.contains(position)) {
             Check_pos.add(position);
             objBlock_Contats.Block_Contats(Check_pos);
       }
     } else if (isChecked == false) {
         for(int i=0;i<Check_pos.size();i++){
            if(Check_pos.elementAt(i)==position){
               Check_pos.removeElementAt(i);
               objBlock_Contats.Block_Contats(Check_pos);
  
            }
          }
      }
    }
});

    if (Check_pos.size() > 0) {
       if (Check_pos.contains(position)){
           holder.chk_contact[position].setChecked(true);
     } else{
            holder.chk_contact[position].setChecked(false);
     }
}
  if (contact_data.get(position).getcontact_name() != null)
          holder.txt_name.setText("Caller Name: "
          + contact_data.get(position).getcontact_name().toString());
  if (contact_data.get(position).getContact_no() != null)
       holder.txt_phone.setText("Caller Number: "
       + contact_data.get(position).getContact_no().toString());

  if (contact_data.get(position).getBitmap() != null) {
      holder.image_caller.getLayoutParams().width = widht;
      holder.image_caller.getLayoutParams().height = height;
      holder.image_caller.setImageBitmap(contact_data.get(position)
      .getBitmap());
   } else
      holder.image_caller
       .setBackgroundResource(R.drawable.icon_passenger);

    return convertView;
}
    public interface Block_Contats{
         public void Block_Contats(Vector<Integer> v);
      }
}

Following xml layout for the contact activity

<?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="match_parent"
   android:orientation="vertical"
   android:background="#F3F2F0">

   <RelativeLayout
     android:id="@+id/LL_search"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:layout_alignParentTop="true"
     android:orientation="horizontal"
     android:padding="@dimen/tow_dp"
   >

   <EditText
      android:id="@+id/edt_search"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:padding="@dimen/ten_dp"
      android:hint="Enter name or mobile no"
      android:layout_toLeftOf="@+id/btm_search" />

    <ImageView
       android:id="@+id/btm_search"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:src="@drawable/search_icon"
       android:layout_alignParentRight="true"
       android:layout_centerVertical="true"
       android:padding="@dimen/ten_dp"/>
    </RelativeLayout>

    <LinearLayout
      android:id="@+id/LL_footerButton"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:layout_alignParentBottom="true"
      android:layout_centerHorizontal="true"
      android:orientation="horizontal"
      android:padding="@dimen/ten_dp"
      android:gravity="center" >

   <Button
     android:id="@+id/btm_add"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:text="Add to blacklist"
     android:background="@drawable/button_email_drawable"/>
</LinearLayout>

    <ListView
     android:id="@+id/list_contact"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:layout_above="@+id/LL_footerButton"
     android:layout_below="@+id/LL_search" />

 </RelativeLayout>

Following is the contact_row.xml which will contain on Imageview to display call photos

<?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="match_parent"
android:clickable="false"
android:padding="@dimen/ten_dp" >

      <ImageView
       android:id="@+id/image_caller"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_alignParentLeft="true"
       android:src="@drawable/icon_passenger" />
     <CheckBox
        android:id="@+id/chk_contact"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:button="@drawable/check_box" 
     />
      <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="@dimen/five_dp"
        android:layout_toLeftOf="@+id/chk_contact"
        android:layout_toRightOf="@+id/image_caller"
        android:orientation="vertical" >

       <TextView
        android:id="@+id/txt_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
         android:text="XYZ" />

      <TextView
        android:id="@+id/txt_phone"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="9999999999" />

    </LinearLayout>


</RelativeLayout>


Thanks
Mahesh Nawale

Comments

Popular posts from this blog

Crypto JS Encryption & Decryption in Android

ListView Over GoogleMapView

Android Interview Material