Tuesday, March 20, 2012

putting multiple date and time wedgets in single activity

 I have a solution that allows for an unlimited number of date fields 
without adding new dialog types. When the user clicks one of the 
buttons, I register which TextView and Calendar is currently being 
modified before launching the DatePickerDialog. The dialog's 
OnDateSetListener then updates the registered TextView and Calendar.
 
 
import java.util.Calendar;
import android.app.Activity;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.app.DatePickerDialog.OnDateSetListener;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.TextView;
public class MultiDatePickerActivity extends Activity {

    private TextView startDateDisplay;
    private TextView endDateDisplay;
    private Button startPickDate;
    private Button endPickDate;
    private Calendar startDate;
    private Calendar endDate;

    static final int DATE_DIALOG_ID = 0;

    private TextView activeDateDisplay;
    private Calendar activeDate;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.multidatepicker);

        /*  capture our View elements for the start date function   */
        startDateDisplay = (TextView) findViewById(R.id.startDateDisplay);
        startPickDate = (Button) findViewById(R.id.startPickDate);

        /* get the current date */
        startDate = Calendar.getInstance();

        /* add a click listener to the button   */
        startPickDate.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                showDateDialog(startDateDisplay, startDate);
            }
        });

        /* capture our View elements for the end date function */
        endDateDisplay = (TextView) findViewById(R.id.endDateDisplay);
        endPickDate = (Button) findViewById(R.id.endPickDate);

        /* get the current date */
        endDate = Calendar.getInstance();

        /* add a click listener to the button   */
        endPickDate.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                showDateDialog(endDateDisplay, endDate);
            }
        });

        /* display the current date (this method is below)  */
        updateDisplay(startDateDisplay, startDate);
        updateDisplay(endDateDisplay, endDate);
    }

    private void updateDisplay(TextView dateDisplay, Calendar date) {
        dateDisplay.setText(
                new StringBuilder()
                    // Month is 0 based so add 1
                    .append(date.get(Calendar.MONTH) + 1).append("-")
                    .append(date.get(Calendar.DAY_OF_MONTH)).append("-")
                    .append(date.get(Calendar.YEAR)).append(" "));

    }

    public void showDateDialog(TextView dateDisplay, Calendar date) {
        activeDateDisplay = dateDisplay;
        activeDate = date;
        showDialog(DATE_DIALOG_ID);
    }

    private OnDateSetListener dateSetListener = new OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            activeDate.set(Calendar.YEAR, year);
            activeDate.set(Calendar.MONTH, monthOfYear);
            activeDate.set(Calendar.DAY_OF_MONTH, dayOfMonth);
            updateDisplay(activeDateDisplay, activeDate);
            unregisterDateDisplay();
        }
    };

    private void unregisterDateDisplay() {
        activeDateDisplay = null;
        activeDate = null;
    }

    @Override
    protected Dialog onCreateDialog(int id) {
        switch (id) {
            case DATE_DIALOG_ID:
                return new DatePickerDialog(this, dateSetListener, activeDate.get(Calendar.YEAR), activeDate.get(Calendar.MONTH), activeDate.get(Calendar.DAY_OF_MONTH));
        }
        return null;
    }

    @Override
    protected void onPrepareDialog(int id, Dialog dialog) {
        super.onPrepareDialog(id, dialog);
        switch (id) {
            case DATE_DIALOG_ID:
                ((DatePickerDialog) dialog).updateDate(activeDate.get(Calendar.YEAR), activeDate.get(Calendar.MONTH), activeDate.get(Calendar.DAY_OF_MONTH));
                break;
        }
    }
}

Saturday, March 10, 2012

Android GUI with Header+Scrollable Content+Footer

 HeaderContentFooterGui.java


package net.pocketmagic.android.HeaderContentFooterGUI;

import android.app.Activity;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.Gravity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;

/* HeaderContentFooterGUI
 *
 * Create a sample GUI with a header bar, scroll-able content and a footer
 *
 * (C) 2011 Radu Motisan, radu.motisan@gmail.com
 * www.pocketmagic.net
 * All rights reserved.
 */

public class HeaderContentFooterGUI extends Activity implements OnClickListener{
   
    final static int        idTopLayout = Menu.FIRST + 100,
                            idBack         = Menu.FIRST + 101,
                            idBotLayout    = Menu.FIRST + 102;
   
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
       
        //Hide titlebar
        requestWindowFeature(Window.FEATURE_NO_TITLE);
       
        //Create our top content holder
        RelativeLayout global_panel = new RelativeLayout (this);
        global_panel.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
        global_panel.setGravity(Gravity.FILL);
       
        // +++++++++++++ TOP COMPONENT: the header
        RelativeLayout ibMenu = new RelativeLayout(this);
         ibMenu.setId(idTopLayout);
        ibMenu.setBackgroundDrawable(getResources().getDrawable(R.drawable.line));
         int ibMenuPadding = (int) 6;
         ibMenu.setPadding(ibMenuPadding,ibMenuPadding,ibMenuPadding,ibMenuPadding);
         RelativeLayout.LayoutParams topParams = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
         topParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
         global_panel.addView(ibMenu,topParams);
         // textview in ibMenu : card holder
        TextView cTV = new TextView(this);
        cTV.setText("Header");
        cTV.setTextColor(Color.rgb(255,255,255));
        int nTextH =  18;
        cTV.setTextSize(nTextH);
        cTV.setTypeface(Typeface.create("arial", Typeface.BOLD));
        RelativeLayout.LayoutParams lpcTV = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        lpcTV.addRule(RelativeLayout.CENTER_IN_PARENT);
        ibMenu.addView(cTV, lpcTV);
        // cancel button in ibMenu
        Button m_bCancel = new Button(this);
        m_bCancel.setId(idBack);
        m_bCancel.setOnClickListener((OnClickListener) this);
        m_bCancel.setText("Cancel");
        nTextH =  12;
        m_bCancel.setTextSize(nTextH);
        m_bCancel.setTypeface(Typeface.create("arial", Typeface.BOLD));
        RelativeLayout.LayoutParams lpbCancel =
            new RelativeLayout.LayoutParams(100,50);//LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        lpbCancel.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
        lpbCancel.addRule(RelativeLayout.CENTER_VERTICAL);
        ibMenu.addView(m_bCancel, lpbCancel);

        // +++++++++++++ BOTTOM COMPONENT: the footer
        RelativeLayout ibMenuBot = new RelativeLayout(this);
        ibMenuBot.setId(idBotLayout);
        ibMenuBot.setBackgroundDrawable(getResources().getDrawable(R.drawable.line));
        ibMenuBot.setPadding(ibMenuPadding,ibMenuPadding,ibMenuPadding,ibMenuPadding);
        RelativeLayout.LayoutParams botParams = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
        botParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
        global_panel.addView(ibMenuBot,botParams);
        // textview in ibMenu : card holder
        TextView cTVBot = new TextView(this);
        cTVBot.setText("www.pocketmagic.net");
        cTVBot.setTextColor(Color.rgb(179,116,197));
        cTVBot.setTextSize(nTextH);
        cTVBot.setTypeface(Typeface.create("arial", Typeface.NORMAL));
        RelativeLayout.LayoutParams lpcTVBot = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        lpcTVBot.addRule(RelativeLayout.CENTER_IN_PARENT);
        ibMenuBot.addView(cTVBot, lpcTVBot);
        
        // +++++++++++++ MIDDLE COMPONENT: all our GUI content
        LinearLayout midLayout = new LinearLayout (this);
        midLayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
        midLayout.setOrientation(LinearLayout.VERTICAL);
        RelativeLayout.LayoutParams midParams = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
        midParams.addRule(RelativeLayout.ABOVE,ibMenuBot.getId());
        midParams.addRule(RelativeLayout.BELOW,ibMenu.getId());
        global_panel.addView(midLayout,midParams );
        //scroll - so our content will be scrollable between the header and the footer
        ScrollView vscroll = new ScrollView(this);
        vscroll.setFillViewport(false);
        midLayout.addView(vscroll);
        //panel in scroll: add all controls/ objects to this layout
        LinearLayout m_panel = new LinearLayout (this);
        m_panel.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
        m_panel.setOrientation(LinearLayout.VERTICAL);
        vscroll.addView(m_panel);
       
        Button b[] = new Button[10];
        for (int i=0;i<6;i++) {
            b[i] = new Button(this);
            b[i].setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
            b[i].setText("But "+i);
            m_panel.addView(b[i]);
        }



        setContentView(global_panel);
    }

    public void onClick(View arg0) {
        // TODO Auto-generated method stub
        int id = arg0.getId();
       
        // If cancel is pressed, close our app
        if (id == idBack) finish();
       
    }
}



no need to write respective .xml file

Wednesday, February 15, 2012

how to inflate 2 or 3 layouts, with its childs ,in one screen programetically

public void horizontalScrollGalleryLayout (List<String> mList3) {
        Integer[] mThumbIds = {
                R.drawable.ds

        };
        Log.i(TAG,"I got call "+"for creation of horizontalgallery");

        LinearLayout ll = new LinearLayout(this, null);
        ll.setOrientation(LinearLayout.VERTICAL);
        ll.setBackgroundColor(Color.WHITE);
        LayoutInflater lf = (LayoutInflater)this.getSystemService(this.LAYOUT_INFLATER_SERVICE);
        ImageButton srchBtn = (ImageButton)lf.inflate(R.layout.searchbtn, null);
        srchBtn.setBackgroundColor(Color.TRANSPARENT);

        srchBtn.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                startActivity(new Intent(CategoryMenu.this,SearchAct.class));
            }
        });

        ll.addView(srchBtn);


        setTitle(R.string.search_instructions);
        mHorScrlView = new HorizontalScrollView(this);
        mLinearlayoutHor = new LinearLayout(this);
        mLinearlayoutHor.setOrientation(LinearLayout.HORIZONTAL);
        mLinearlayoutHor.setBackgroundColor(color.white);
        mLayoutParamsTV = new LinearLayout.LayoutParams(75,75);
        mLayoutParamsTV.setMargins(12, 25, 12, 12);
        mLayoutParamsLL = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        mLayoutParamsLL.setMargins(2,2,2,2);
        mLayoutParamsLLD = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT);
        Log.e(TAG,"in horizantal "+"scroll view 1");
      
        for(int k=0;k<mList3.size();k++)
        { 

            if(mList3.size()==mTotal)
            {
                break;
            }

            mLinearLayoutVer = new LinearLayout(this);

            for (int i=0; i<3; i++) {

                mLinearLayoutVer.setOrientation(LinearLayout.VERTICAL);
                mLinearLayourFrame = new LinearLayout(this);
                mLinearLayourFrame.setBackgroundResource(R.drawable.layout_border1);
                mLinearLayourFrame.setOrientation(LinearLayout.VERTICAL);
                mImgView = new ImageView(this);
                mtxt = new TextView(this);
                mCat = new Category();

                try {

                    mImgView.setImageResource(mThumbIds[0]);
                    mImgView.setTag(mList3.get(mTotal));
                    mtxt.setText(mList3.get(mTotal));
                    mtxt.setTextColor(Color.BLUE);
                    mtxt.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
                }
                catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                mLinearLayourFrame.addView(mImgView,mLayoutParamsTV);
                mLinearLayourFrame.addView(mtxt);
                mLinearLayourFrame.setTag(mList3.get(mTotal));
              
                mLinearLayourFrame.setOnClickListener(new View.OnClickListener() {

                    public void onClick(View view) {
                        // Perform action on click
                        CharSequence cat = (CharSequence) view.getTag();
                        Log.e(TAG,"imgTag after category clicked "+ cat);
                        CharSequence category = cat;
                        mCat=mAppMgr.getCategoryObjectFromName(category);

                        String isleaf = mCat.getIs_leaf();
                        String parent_id=mCat.getParent_id();
                        String cat_id=mCat.getCategory_id();
                        Log.e(TAG,"cat_id : "+cat_id);
                        String cat_name=mCat.getCategory_name();
                        Log.e(TAG,"isleaf : "+isleaf);

                        if(isleaf.equals("false"))
                        {
                            Intent i=new Intent(CategoryMenu.this,SubCategoryMenu.class);
                            Log.d(TAG,"false executed"+"Thanks");
                            i.putExtra("cat",cat_id);
                            i.putExtra("cat_name",cat);
                            i.putExtra("view", Globals.CONST_SUBCATEGORY);
                            startActivity(i);
                        }

                        else
                        {
                            Intent i=new Intent(CategoryMenu.this,ProfilesList.class);
                            Log.d(TAG,"true executed"+"Thanks");
                            mAppctx.setCatId(cat_id);
                            mAppctx.setCatName(cat_name);
                            startActivity(i);
                        }

                        Log.e(TAG,"am in"+"sub categories");
                    }
                });

                new DownloadImageAsyncTask(mList.get(mTotal),mImgView,"category_img",mTotal).execute(Configure.SM_SERVER_URL_PREFIX+(mCatUrls.get(mTotal)));
                mTotal++;

            //}
                mLinearLayoutVer.addView(mLinearLayourFrame, mLayoutParamsLL);
              
                if(mList3.size()==mTotal)
                    break;

            }

            mLinearlayoutHor.addView(mLinearLayoutVer);
            mLinearlayoutHor.setBackgroundColor(Color.WHITE);
            mLinearlayoutHor.setHorizontalScrollBarEnabled(false);
            //mLinearLayourFrame.setClickable(true);
        }
    mHorScrlView.addView(mLinearlayoutHor, mLayoutParamsLLD);
    mHorScrlView.setHorizontalScrollBarEnabled(false);
    ll.addView(mHorScrlView);
    lf = (LayoutInflater)this.getSystemService(this.LAYOUT_INFLATER_SERVICE);
    View convertView = lf.inflate(R.layout.buttons_myaccount, null);
    Button myAccntBtn = (Button) convertView.findViewById(R.id.MyAccountBtn);
    Button myChatBtn = (Button) convertView.findViewById(R.id.ChatBtn);
    myAccntBtn.setOnClickListener(new View.OnClickListener(){

        @Override
        public void onClick(View v) {
            Log.e(TAG,"button My Account clicked");

            if(CategoryMenu.mStatus){
                Log.d(TAG,"am in"+"login status true" );
                MyAccount.mCurrentView1=Globals.SENT_FROM_SPLIST;
                Intent i=new Intent(CategoryMenu.this,MyAccount.class);
                startActivity(i);
            }

            else
            {
                LoginInfo.mCurrentView1=Globals.LOGIN_IN_MYACCOUNT;
                Intent i=new Intent(CategoryMenu.this,LoginInfo.class);
                startActivity(i);

            }
        }

    });
  
    ll.addView(convertView);
    setContentView(ll);
  

}


buttons_myaccount.xml

<?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="horizontal">
        <Button android:id="@+id/MyAccountBtn" android:text="MyAccount"
            android:layout_width="fill_parent" android:layout_height="fill_parent"
            android:textColor="@color/menu_buttons"
            android:gravity="center"
            android:layout_alignParentBottom="true"
            android:layout_weight="1"
            android:background="@drawable/button_menu"/>
        <Button android:id="@+id/ChatBtn" android:text="Chat"
            android:layout_width="fill_parent" android:layout_height="fill_parent"
             android:textColor="@color/menu_buttons"
            android:gravity="center"
            android:layout_alignParentBottom="true"
            android:layout_weight="1"
            android:background="@drawable/button_menu"/>
        <Button android:id="@+id/MoreBtn" android:text="More.."
            android:layout_width="fill_parent" android:layout_height="fill_parent"
             android:textColor="@color/menu_buttons"
            android:gravity="center"
            android:layout_alignParentBottom="true"
            android:layout_weight="1"
            android:background="@drawable/button_menu"/>
    </LinearLayout>


searchbtn.xml

<?xml version="1.0" encoding="utf-8"?>
<ImageButton
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/srchbtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/searchnew"
android:layout_gravity="left"/>

Wednesday, February 8, 2012

how to query database , wiht bean class which have diffrent tables.

ServiceProvider.java

public class ServiceProvider {

     public String profile_id;
     public String category_id;
     public String profile_name;
     public String profile_des;
   
     public String country;
     public String city;
     public String profile_pic_url;
     public String loginname;
     public  ArrayList<UserComments> usercommentsList;
     public String rating;

   

    public String videoid;
    public String is_online;
    public String is_service_provider;
    public ArrayList<Service1> serviceList;
    public ArrayList<Phnos>phnoList;

    public ArrayList<EmailIds>email_idList;
    public String acname;
    public String bankname;
    public String acno;
    public String status;


}

EmailIds.java


public class EmailIds implements Parcelable {
    public String profileid;
    public String emailid;
    public String emailtype;
    @Override
    public int describeContents() {
        // TODO Auto-generated method stub
        return 0;
    }
    @Override
    public void writeToParcel(Parcel dest, int flags) {
        // TODO Auto-generated method stub
        dest.writeString(profileid);
        dest.writeString(emailid);
        dest.writeString(emailtype);
    }
    public static final Parcelable.Creator<EmailIds> CREATOR
    = new Parcelable.Creator<EmailIds>() {
        public EmailIds createFromParcel(Parcel in) {
            return new EmailIds(in);
        }

        public EmailIds[] newArray(int size) {
            return new EmailIds[size];
        }
    };

    public EmailIds(Parcel in) {
        if(in!=null){
        profileid = in.readString();
        emailid=in.readString();
        emailtype=in.readString();
        }
}
    public EmailIds() {

    }
}
query which gets details



Service1.java


public class Service1 implements Parcelable {
     public String service_id;
     public String service_name;
     public String service_des;
     public String service_charge;
     public String sp_profile_id;
     public String payment_timestamp;
     public String sub_validity;
     public String timeslot;
     @Override
        public int describeContents() {
            // TODO Auto-generated method stub
            return 0;
        }
        @Override
        public void writeToParcel(Parcel dest, int flags) {
            // TODO Auto-generated method stub
           
            dest.writeString(service_id);
            dest.writeString(service_name);
            dest.writeString(service_des);
            dest.writeString(service_charge);
            dest.writeString(timeslot);
           
            dest.writeString(sp_profile_id);
            dest.writeString(payment_timestamp);
            dest.writeString(sub_validity);
           
        }
        public static final Parcelable.Creator<Service1> CREATOR
        = new Parcelable.Creator<Service1>() {
            public Service1 createFromParcel(Parcel in) {
                return new Service1(in);
            }

            public Service1[] newArray(int size) {
                return new Service1[size];
            }
        };

        public Service1(Parcel in) {
            if(in!=null){
                service_id=in.readString();;
                service_name=in.readString();
                 service_des=in.readString();
                  service_charge=in.readString();
                  timeslot=in.readString();
                  sp_profile_id=in.readString();
                  payment_timestamp=in.readString();
                  sub_validity=in.readString();
               
            }
    }
        public Service1() {

        }
}



UserComments.java


public class UserComments implements Parcelable {
    public String nu_profileid;
    public String sp_profileid;
    public String userComments;
    public String name;
    public String rating;
    @Override
    public int describeContents() {
        // TODO Auto-generated method stub
        return 0;
    }
    @Override
    public void writeToParcel(Parcel dest, int flags) {
        // TODO Auto-generated method stub
       
        dest.writeString(nu_profileid);
        dest.writeString(userComments);
        dest.writeString(name);
        dest.writeString(rating);
        dest.writeString(sp_profileid);
    }
    public static final Parcelable.Creator<UserComments> CREATOR
    = new Parcelable.Creator<UserComments>() {
        public UserComments createFromParcel(Parcel in) {
            return new UserComments(in);
        }

        public UserComments[] newArray(int size) {
            return new UserComments[size];
        }
    };

    public UserComments(Parcel in) {
        if(in!=null){
            nu_profileid=in.readString();;
            userComments=in.readString();
            name=in.readString();
            rating=in.readString();
            sp_profileid=in.readString();
           
        }
}
    public UserComments() {

    }
}


Phnos.java


public class Phnos implements Parcelable{
    public String profileid;
    public String phno;
    public String phnotype;
   
    @Override
    public int describeContents() {
        // TODO Auto-generated method stub
        return 0;
    }
    @Override
    public void writeToParcel(Parcel dest, int flags) {
        // TODO Auto-generated method stub
        dest.writeString(profileid);
        dest.writeString(phno);
        dest.writeString(phnotype);
   
    }
    public static final Parcelable.Creator<Phnos> CREATOR
    = new Parcelable.Creator<Phnos>() {
        public Phnos createFromParcel(Parcel in) {
            return new Phnos(in);
        }

        public Phnos[] newArray(int size) {
            return new Phnos[size];
        }
    };

    public Phnos(Parcel in) {
        if(in!=null){
        profileid = in.readString();
        phno=in.readString();
        phnotype=in.readString();
        }
    }
   
    public Phnos() {

    }


}

/**
     *  method that get service provider profile  from database table
     *
     */
    public ArrayList<ServiceProvider> getProviderProfiles(String profile_id){
        ArrayList<ServiceProvider> profiles = new ArrayList<ServiceProvider>();
        SQLiteDatabase database = this.getWritableDatabase();
        ArrayList<UserComments> usercommentsList=new ArrayList<UserComments>();
        UserComments userComments;
        EmailIds emailid;
        ArrayList<EmailIds> emailidList=new ArrayList<EmailIds>();
        String sp_profileid=null;
        Service1 service;
        ArrayList<Service1> servicesList=new ArrayList<Service1>();
        ArrayList<Phnos> PhnosList=new ArrayList<Phnos>();
        Phnos pHno;
        Log.e("nu_profileid",""+profile_id);
        //    Cursor data2 =database.rawQuery("SELECT * form nu_subscriptions where nu_profile_id="+profile_id,null);
        Cursor data2 = database.query("nu_subscriptions", new String[] {"sp_profile_id"},new String("nu_profile_id"+"=?"),new String[]{profile_id.toString()}, null, null, null);


        if (data2!= null)
        {
            //    Log.d(TAG+"database",database.toString());


            if (data2.moveToFirst()){
                do{
                    sp_profileid=data2.getString(data2.getColumnIndex("sp_profile_id"));
                    Log.e("sp_profileid",""+sp_profileid);
                    //Cursor data1 = database.rawQuery("select profile_name,profile_des,country,city,profile_id,rating,is_online,acno,bankname, acname from SM_profile1 where profile_id="+sp_profileid, null);
                    Cursor data1=database.query("SM_profile1", new String[] {"login_id,profile_name","profile_des","country","city","profile_id","rating","is_online","is_updated","SP_profile_pic_url"},new String("profile_id"+"=?"),new String[]{sp_profileid.toString()}, null, null, null);
                    Cursor data4 = database.query("SM_email_id1", new String[] {"email_id"},new String("profile_id"+"=?"),new String[]{sp_profileid.toString()}, null, null, null);
                    Cursor data5 = database.query("SM_phone_numbers", new String[] {"contact_number"},new String("profile_id"+"=?"),new String[]{sp_profileid.toString()}, null, null, null);
                    Cursor data3 = database.query("SM_user_comments1", new String[] {"user_comments"},new String("profile_id"+"=?"),new String[]{sp_profileid.toString()}, null, null, null);
                    Cursor data6 = database.query("SP_services1", new String[] {"service_id","service_name" ,"service_charge","profile_id"},new String("profile_id"+"=?"),new String[]{sp_profileid.toString()}, null, null, null);
                    ServiceProvider pf=new ServiceProvider();
                    if (data6.moveToFirst()){
                        do{
                            //    servicesList=new ArrayList<Service1>();
                            //servicesList.clear();
                            String service_id= data6.getString(data6.getColumnIndex("service_id"));
                            Log.e("service_id",""+service_id);
                            String service_name= data6.getString(data6.getColumnIndex("service_name"));
                            String sp_profile_id= data6.getString(data6.getColumnIndex("profile_id"));
                            //String payment_timestamp= data2.getString(data2.getColumnIndex("payment_timestamp"));
                            String service_charge= data6.getString(data6.getColumnIndex("service_charge"));
                            //int isupdate=data6.getInt(data6.getColumnIndex("is_updated"));
                            //if(isupdate==0){
                            service=new Service1();
                            service.service_id =service_id ;

                            service.service_charge = service_charge;
                            service.service_name= service_name;
                            service.sp_profile_id=sp_profile_id;
                            //     service.service_des= service_des;
                            servicesList.add(service);
                            //}
                            pf.serviceList=servicesList;
                            //pf.serviceList.clear();
                            Log.e(TAG,""+pf.serviceList.size());
                            for(int i=0;i<pf.serviceList.size();i++){
                                Log.e(TAG,pf.serviceList.get(i).service_id);
                            }
                        }while (data6.moveToNext());
                    }
                    if (data4.moveToFirst()){
                        String emailid1=data4.getString(data4.getColumnIndex("email_id"));
                        emailid=new EmailIds();
                        Log.e(" emailid", emailid1);
                        emailid.emailid =emailid1;
                        emailidList.add(emailid);
                        pf.email_idList=emailidList;
                    }
                    if (data5.moveToFirst()){
                        String contactnumber=data5.getString(data5.getColumnIndex("contact_number"));
                        pHno=new Phnos(null);
                        Log.e("contactnumber",contactnumber);
                        pHno.phno =contactnumber;
                        PhnosList.add(pHno);
                        pf.phnoList=PhnosList;
                    }
                    if (data3.moveToFirst())
                    {
                        String userComment1=data3.getString(data3.getColumnIndex("user_comments"));
                        userComments=new UserComments();
                        userComments.userComments = userComment1;
                        usercommentsList.add( userComments);
                        pf.usercommentsList=usercommentsList;
                    }
                    if (data1!= null)
                    {
                        Log.d(TAG+"database",database.toString());


                        if (data1.moveToFirst()){
                            //do{
                            Log.d(TAG,"am in curser data1");
                            String provider = data1.getString(data1.getColumnIndex("profile_name"));

                            String Country = data1.getString(data1.getColumnIndex("country"));
                            String profileid = data1.getString(data1.getColumnIndex("profile_id"));
                            String rating = data1.getString(data1.getColumnIndex("rating"));
                            String is_online= data1.getString(data1.getColumnIndex("is_online"));
                            String pic_url=data1.getString(data1.getColumnIndex("SP_profile_pic_url"));
                            String loginid=data1.getString(data1.getColumnIndex("login_id"));
                            //    String usercomments=data1.getString(data1.getColumnIndex("usercomments"));
                            //String acname=data1.getString(data1.getColumnIndex("acname"));
                            //String bankname=data1.getString(data1.getColumnIndex("bankname"));
                            //String acno=data1.getString(data1.getColumnIndex("acno"));
                            int isupdated=data1.getInt(data1.getColumnIndex("is_updated"));
                            if(isupdated==1){
                                pf.country=Country;
                                Log.d("pf.country",pf.country);
                                pf.profile_id=profileid;
                                Log.d("profile_id",pf.profile_id);
                                pf.profile_name=provider;
                                Log.d("profile_name",pf.profile_name);
                                pf.is_online=is_online;
                                pf.profile_pic_url=pic_url;
                                pf.loginname=loginid;
                                //pf.acname=acname;
                                //pf.acno=acno;
                                //pf.bankname=bankname;
                                pf.rating=rating;
                            }
                            //pf.videoid=videoid;
                            //    Log.d(TAG,pf.videoid);


                            //}while (data1.moveToNext());

                        }

                        //database.close();
                    }

                    profiles.add(pf);
                }while (data2.moveToNext());
                Log.e(TAG+"profiles size",""+profiles.size());
                data2.close();
                //    data1.close();
            }

        }


/**
     *  method that get service provider profile  from database table
     *
     */
    public ArrayList<ServiceProvider> getProfiles(String key){
        ArrayList<ServiceProvider> profiles = new ArrayList<ServiceProvider>();
        SQLiteDatabase database = this.getWritableDatabase();

        String profile_id=null;
        Service1 service;
        Cursor data,data1,data2,data3 ;


        ArrayList<Service1> servicesList=new ArrayList<Service1>();
        ArrayList<UserComments> usercommentsList=new ArrayList<UserComments>();
        UserComments userComments;

        data = database.query("SP_Profile_categories", new String[] {"profile_id"},new String("category_id"+"=?"),new String[]{key.toString()}, null, null, null);

        if (data.moveToFirst())
        {
            do{

               
                    profile_id= data.getString(data.getColumnIndex("profile_id"));
                    Log.d(TAG+"profile_id",profile_id);
               



                //data.close();
                data3 = database.query("SM_user_comments1", new String[] {"user_comments"},new String("profile_id"+"=?"),new String[]{profile_id.toString()}, null, null, null);
                System.out.println(data3);
                data2 = database.query("SP_services1", new String[] {"service_id","service_name" ,"service_description","service_charge"},new String("profile_id"+"=?"),new String[]{profile_id.toString()}, null, null, null);

                data1 = database.query("SM_profile1", new String[] {"login_id,profile_name,country,profile_id,profile_des,SP_profile_pic_url"},new String("profile_id"+"=?"),new String[]{profile_id.toString()}, null, null, null);
                if (data1!= null)
                {
                    Log.d(TAG+"database",database.toString());


                    if (data1.moveToFirst()){
                        do{
                            Log.d("database helper classs get profiles",profile_id);
                            String provider = data1.getString(data1.getColumnIndex("profile_name"));   
                            String Country = data1.getString(data1.getColumnIndex("country"));
                            String profileid = data1.getString(data1.getColumnIndex("profile_id"));
                            String profiledes = data1.getString(data1.getColumnIndex("profile_des"));
                            String profile_url=data1.getString(data1.getColumnIndex("profile_pic_url"));
                            String loginid=data1.getString(data1.getColumnIndex("login_id"));
                            ServiceProvider pf=new ServiceProvider();
                            if (data2.moveToFirst())
                            {

                                String service_id=data2.getString(data2.getColumnIndex("service_id"));
                                String service_name=data2.getString(data2.getColumnIndex("service_name"));
                                String service_des=data2.getString(data2.getColumnIndex("service_description"));
                                String service_charge=data2.getString(data2.getColumnIndex("service_charge"));
                                service=new Service1();
                                service.service_id =service_id ;
                                service.service_charge = service_charge;
                                service.service_name= service_name;
                                service.service_des= service_des;
                                servicesList.add(service);
                                pf.serviceList=servicesList;

                            }
                            if (data3.moveToFirst())
                            {
                                String userComment1=data3.getString(data3.getColumnIndex("user_comments"));
                                userComments=new UserComments();
                                userComments.userComments = userComment1;
                                usercommentsList.add(userComments);
                                pf.usercommentsList=usercommentsList;
                            }
                            pf.country=Country;
                            Log.d("pf.country",pf.country);
                            pf.profile_id=profileid;
                            Log.d("profile_id",pf.profile_id);
                            pf.profile_name=provider;
                            Log.d("profile_name",pf.profile_name);
                            pf.profile_des=profiledes;
                            pf.profile_pic_url=profile_url;
                            Log.e(TAG,"pf.profile_pic_url"+pf.profile_pic_url);
                            pf.loginname=loginid;
                            profiles.add(pf);

                        }while (data1.moveToNext());
                    }
                }
            }while (data.moveToNext());


            data1.close();
            data2.close();
            data3.close();
       
            Log.e(TAG+"profiles size",""+profiles.size());
            database.close();
        }
       



        return profiles;
    }

same we store data into database when we read from server response.


/**
     * This method creates the Profile at client side[local_Database] .
     */
    public static void createProfiles(DatabaseHelper mDBHelper, String key) {
        SQLiteDatabase database = mDBHelper.getWritableDatabase();   

        ContentValues values3 = new ContentValues();
        ContentValues valuescat = new ContentValues();
        int j=0;
        Log.e(TAG,"mProfiles.size()"+mProfiles.size());
        database.execSQL("delete from  SP_Profile_categories");
        for(;j<mProfiles.size();j++){
            String profile_id = mProfiles.get(j).profile_id;
            String category_id = key;
            valuescat.put("profile_id",profile_id);
            valuescat.put("category_id",category_id);
            Log.d(TAG,"category_id"+category_id);
            Log.e(TAG,profile_id);
            database.insert("SP_Profile_categories", null,valuescat);
        }
        int i =0;
        database.execSQL("delete from  SM_profile1 ");
        Log.e(TAG+"all records deleted ","from SM_profile1");
        ContentValues valueser = new ContentValues();
        ContentValues valuecomments = new ContentValues();

        for(;i<mProfiles.size();i++){
            String profile_id = mProfiles.get(i).profile_id;
           
            //    String category_id = mProfiles.get(i).category_id;
            String profile_name=mProfiles.get(i).profile_name;
            String profile_des = mProfiles.get(i).profile_des;
            String country=mProfiles.get(i).country;
            String city = mProfiles.get(i).city;
            String is_online=mProfiles.get(i).is_online;
            ///String acno=mProfiles.get(i).acno;
            //String acname= mProfiles.get(i).acname;
            //    String bankname=mProfiles.get(i).bankname;
            //String videoid = mProfiles.get(i).videoid;
           
            String rating=mProfiles.get(i).rating;
            String profile_pic_url=mProfiles.get(i).profile_pic_url;
            Log.d(TAG,"profile_id"+profile_id);
            values3.put("profile_id",profile_id);
            values3.put("is_online",is_online);
            //Log.d("category_id",""+category_id);
            values3.put("profile_name",profile_name);
            values3.put("profile_des",profile_des);
            values3.put("country",country);
            values3.put("city",city);

            values3.put("rating",rating);
            values3.put("SP_profile_pic_url",profile_pic_url);
            //values3.put("videoid",videoid);
            database.insert("SM_profile1", null, values3);


       
        ArrayList<UserComments> usercomments = mProfiles.get(0).usercommentsList;

            for( j=0;j<usercomments.size();j++)
            {
                String userComments=usercomments.get(j).userComments;
                String profileid=profile_id;
                valuecomments .put("profile_id",profileid);
                valuecomments .put("user_comments",userComments );
                database.insert("SM_user_comments1", null,valuecomments);
            }
            ArrayList<Service1>serviceList= mProfiles.get(0).serviceList;
            for(j=0;j<serviceList.size();j++)
            {
                String profileid=profile_id;
                String service_id=serviceList.get(j).service_id;
                String service_name=serviceList.get(j).service_name;
                String service_des=serviceList.get(j).service_des;
                String service_charge=serviceList.get(j).service_charge;
                valueser.put("profile_id",profileid);
                valueser.put("service_id",service_id);
                valueser.put("service_name",service_name);
                valueser.put("service_description",service_des);
                valueser.put("service_charge",service_charge);
                database.insert("SP_services1", null,valueser);
            }

            //valueser.put("profile_id",profile_id);
       
        Log.e(TAG+"mProfiles.size()",""+mProfiles.size());

    }
    }



public static void createMySubscribersDetails(DatabaseHelper mDBHelper,String key) {
        SQLiteDatabase database = mDBHelper.getWritableDatabase();   
        //database.execSQL("delete from nu_subscriptions");
        ContentValues valuesub = new ContentValues();

        ContentValues value1 = new ContentValues();
        String nu_profile_id=null;
        String profile_name=null;
        String sp_profile_id1;
        ArrayList<Service1> subscribersList=new ArrayList<Service1>();
        int j=0;
        for(;j<mMysubscriber.size();j++){
            sp_profile_id1=key;
            nu_profile_id=mMysubscriber.get(j).nu_profile_id;
            profile_name= mMysubscriber.get(j).nu_profile_name;
            String nu_country=mMysubscriber.get(j).nu_country;
            Log.e("profile_name",""+profile_name);
            Log.e("nu_country",""+nu_country);
            value1.put("profile_id",nu_profile_id);
            value1.put("profile_name",profile_name);
            value1.put("country",nu_country);
            database.insert("SM_profile1", null, value1);


            subscribersList=mMysubscriber.get(j).serviceList;

            Log.e(TAG,"subscribersList.size()"+subscribersList.size());
            String service_id=subscribersList.get(j).service_id;
            String service_name=subscribersList.get(j).service_name;
            String validity=subscribersList.get(j).sub_validity;
            Log.e(TAG,"subscribersList.get(i).service_charge"+subscribersList.get(j).service_charge);

            Float service_charge=Float.parseFloat(subscribersList.get(j).service_charge);
            valuesub.put("sp_profile_id",key);
            valuesub.put("nu_profile_id",nu_profile_id);
            valuesub.put("service_id",service_id);
            valuesub.put("service_name",service_name);
            valuesub.put("sub_validity",validity);
            valuesub.put("service_charge",service_charge);
            database.insert("nu_subscriptions", null,valuesub);

        }           


    }

    /*when row recvd is partial, then if row doesnot exist in local table and isupdated is false   insert else leave as is
   when row recvd is full, if row exists, update row with isupdated true. else, insert row and set isupdated to true*/
    public static void createMySPProfiles(DatabaseHelper mDBHelper, String key) {
        SQLiteDatabase database = mDBHelper.getWritableDatabase();   
        ContentValues valueph= new ContentValues();
        ContentValues valuemailid= new ContentValues();
        ContentValues values3 = new ContentValues();
        ContentValues nuprofiles= new ContentValues();
        ContentValues valuecomments = new ContentValues();
        //database.execSQL("delete from  nu_subscriptions");
        int j=0;

        int i =0;
        //database.execSQL("delete from  SM_profile1 ");
        //Log.e(TAG+"all records deleted ","from SM_profile1");
        ContentValues valueser = new ContentValues();
        for(;i<mMySPProfiles.size();i++){
            String profile_id = mMySPProfiles.get(i).profile_id;
            //    String category_id = mProfiles.get(i).category_id;
            String profile_name=mMySPProfiles.get(i).profile_name;
            //String profile_des = mProfiles.get(i).profile_des;
            String country=mMySPProfiles.get(i).country;
            String city = mMySPProfiles.get(i).city;

            String rating=mMySPProfiles.get(i).rating;
            //    String service_id=mProfiles.get(i).service_id;
            String is_online=mMySPProfiles.get(i).is_online;
            Log.d(TAG,"profile_id"+profile_id);
        String profile_pic=mMySPProfiles.get(i).profile_pic_url;
            Log.d(TAG,"profile_pic"+profile_pic);    
            String loginame=mMySPProfiles.get(i).loginname;
            Log.e(TAG,"loginame"+loginame);
        //    values3.put("profile_name",profile_name);
        //    values3.put("acno",acno);
        //    values3.put("acname",acname);
            //values3.put("bankname",bankname);
            //values3.put("country",country);
            //values3.put("city",city);

            //values3.put("acno",acno);
            //.put("acname",acname);
            //.put("bankname",bankname);





            Cursor data1 = database.query("SM_profile1", new String[] {"is_updated","profile_id"},new String("profile_id"+"=?"),new String[]{profile_id.toString()}, null, null, null);
            if(data1!=null){
               
                if (data1.moveToFirst()){
                    do{
                       
                        String profileid= data1.getString(data1.getColumnIndex("profile_id"));
                        int isupdate= data1.getInt(data1.getColumnIndex("is_updated"));
                        Log.e(TAG,"isupdate"+isupdate);
                        Log.e(TAG,"sp_profile_id"+profileid);
                        values3.put("is_online",is_online);
                        Log.d(TAG,"profile_name"+profile_name);    
                        values3.put("profile_name",profile_name);
                        values3.put("country",country);
                        values3.put("city",city);
                        values3.put("is_updated",1);
                        values3.put("rating",rating);
                        values3.put("SP_profile_pic_url",profile_pic);
                        values3.put("login_id",loginame);
                        //login_id
                    }while(data1.moveToNext());
                    data1.close();
                    database.update("SM_profile1",values3,"profile_id=?",new String[] {(profile_id.toString())});
                }   

                else{
                   
                    Log.e(TAG,"sp_profile_id"+profile_id);
                    values3.put("is_online",is_online);
                    Log.d(TAG,"profile_name"+profile_name);    
                    values3.put("profile_name",profile_name);
                    values3.put("country",country);
                    values3.put("city",city);
                    values3.put("is_updated",1);
                    values3.put("rating",rating);
                    values3.put("profile_id",profile_id);
                    values3.put("login_id",loginame);
                    values3.put("SP_profile_pic_url",profile_pic);
                    database.insert("SM_profile1", null, values3);

                }
            }
            //values3.put("videoid",videoid);
            //database.insert("SM_profile1", null, values3);
        }

        i=0;
        ArrayList<UserComments> usercomments = mMySPProfiles.get(i).usercommentsList;

        ArrayList<Service1>serviceList=mMySPProfiles.get(i).serviceList;
        ArrayList<EmailIds> emailList=mMySPProfiles.get(i).email_idList;
        Log.e("emailList",""+emailList.size());
        ArrayList<Phnos> phNoList=mMySPProfiles.get(i).phnoList;
        Log.e(" phNoList",""+ phNoList.size());
        database.execSQL("delete from SM_email_id1");
        database.execSQL("delete from SM_phone_numbers");
        for(j=0;j<usercomments.size();j++)
        {
            String userComments=usercomments.get(j).userComments;
            String sp_profile_id = usercomments.get(j).sp_profileid;
            String profileid=sp_profile_id;
            valuecomments .put("profile_id",sp_profile_id);
            valuecomments .put("user_comments",userComments );
            database.insert("SM_user_comments1", null,valuecomments);
        }
        for(j=0;j<emailList.size();j++)
        {
            String emailid=emailList.get(j).emailid;
            String sp_profile_id =emailList.get(j).profileid;
            //String profileid=profile_id;
            valuemailid.put("profile_id", sp_profile_id);
            valuemailid.put("email_id",emailid);
            database.insert("SM_email_id1", null,valuemailid);
        }
        for(j=0;j<phNoList.size();j++)
        {
            //String sp_profile_id = mMySPProfiles.get(i).profile_id;
            String phNo=phNoList.get(j).phno;
            String profileid=phNoList.get(j).profileid;
            valueph.put("profile_id",profileid);
            valueph.put("contact_number",phNo);
            database.insert("SM_phone_numbers", null,valueph);
        }
        for(j=0;j<serviceList.size();j++)
        {
            Log.e(TAG,"serviceList.size()"+serviceList.size());
            String sp_profile_id = serviceList.get(j).sp_profile_id;
            Log.e(TAG,"sp_profile_id"+sp_profile_id);
            String service_id=serviceList.get(j).service_id;
            Log.e(TAG,"service_id"+service_id);
            String service_name=serviceList.get(j).service_name;
            //    String service_des=serviceList.get(j).service_des;
            String service_charge=serviceList.get(j).service_charge;
            Log.e(TAG,"key"+key);
            Cursor data2 = database.rawQuery("SELECT profile_id,service_id from SP_services1 where profile_id="+"?"+"AND service_id="+"?" ,new String[]{sp_profile_id.toString(),service_id.toString()});
            Log.e(TAG,"data2.moveToFirst()"+data2.moveToFirst());
            if (data2.moveToFirst()){
                do{
                   
                    String profileid= data2.getString(data2.getColumnIndex("profile_id"));
                    String serviceid= data2.getString(data2.getColumnIndex("service_id"));
                    //String nu_profile_id=data2.getString(data2.getColumnIndex("nu_profile_id"));
                    //int isupdate= data2.getInt(data2.getColumnIndex("is_updated"));
                    //    valueser.put("is_updated",0);
                    Log.e(TAG,"sp_profile_id"+profileid);
                    //database.insert("nu_subscriptions", null,valueser);
                    //database.update("nu_subscriptions",values3,"sp_profile_id=?,service_id=?,nu_profile_id=?",new String[] {(profileid.toString()),serviceid.toString(),nu_profile_id.toString()});

                }while(data2.moveToNext());
                data2.close();
            }                       
            else
            {
           

                valueser.put("profile_id",sp_profile_id);
               
                valueser.put("service_id",service_id);
                valueser.put("service_name",service_name);
                //valueser.put("payment_timestamp",payment_timestamp);
                valueser.put("service_charge",service_charge);
                //valueser.put("is_updated",0);
                database.insert("SP_services1", null,valueser);
                Cursor data3= database.rawQuery("SELECT sp_profile_id,nu_profile_id,service_id from nu_subscriptions where sp_profile_id="+"?"+" AND nu_profile_id="+"?"+" AND service_id="+"?" ,new String[]{sp_profile_id.toString(),key.toString(),service_id.toString()});
                Log.e(TAG,"data3.moveToFirst()"+data3.moveToFirst());
                if (data3.moveToFirst()){
                    do{
                   
                        String profileid= data3.getString(data3.getColumnIndex("sp_profile_id"));
                        String serviceid= data3.getString(data3.getColumnIndex("nu_profile_id"));
                        //String nu_profile_id=data2.getString(data2.getColumnIndex("nu_profile_id"));
                        //int isupdate= data2.getInt(data2.getColumnIndex("is_updated"));
                        //    valueser.put("is_updated",0);
                        Log.e(TAG,"sp_profile_id"+profileid);
                        //database.insert("nu_subscriptions", null,valueser);
                        //database.update("nu_subscriptions",values3,"sp_profile_id=?,service_id=?,nu_profile_id=?",new String[] {(profileid.toString()),serviceid.toString(),nu_profile_id.toString()});

                    }while(data3.moveToNext());
                    data3.close();
                }   
                else{
                    nuprofiles.put("service_id",service_id);
                nuprofiles.put("sp_profile_id",sp_profile_id);
                nuprofiles.put("nu_profile_id",key);
                nuprofiles.put("is_updated",0);
                database.insert("nu_subscriptions",null,nuprofiles);
                }
            }
           

        }

the json resopnse we parse is :


/**
     *  method to parse SubscriberDetails coming from server
     *
     */
    public static List<MySubscriberDetails>parseMySubsciber(String jsonString)
    {
        mMysubscriber = new ArrayList<MySubscriberDetails>();
        try {
            JSONObject jObject = new JSONObject(jsonString);

            /*{"subcribers":[["3003","Vamshi D","india",[["7001","Computer Engineering by Chakri","2011-09-
             * 10 12:43:01.0","100.0","2012-09-10 06:46:29.0"]]],["3001","Faiyaz","canada",[["7001","Computer En
             * gineering by Chakri","2011-09-10 12:46:18.0","100.0","2012-09-10 06:46:29.0"]]],["3005","suresh M
             * ","india",[["7001","Computer Engineering by Chakri","2011-09-10 12:46:09.0","100.0","2012-09-10 06:46:29.0"]]],
             * ["3007","nayana Ch","india",[["7001","Computer Engineering by Chakri","2011-09-10 12:4
             * 5:58.0","100.0","2012-09-10 06:46:29.0"]]]]}*/


            JSONArray menuitemArray1 = jObject.getJSONArray("subcribers");
            Log.d(TAG+"menuitemArray1",""+menuitemArray1.length());


            Service1 service;
            ArrayList<Service1> servicesList=new ArrayList<Service1>();
            for(int i=0 ;i<menuitemArray1.length();i++){
                ServiceProvider pfl=new ServiceProvider();
                JSONArray tempArray = menuitemArray1.getJSONArray(i);
                Log.e("menuitemArray1 size",""+menuitemArray1.length());
                Log.e("tempArray.length()",""+tempArray.length());

                int k=0;
                Log.d("subcribers", tempArray.getString(k));
                Log.d("subcribers", tempArray.getString(++k));
                Log.d("subcribers", tempArray.getString(++k));

                MySubscriberDetails inf=new MySubscriberDetails();
                k=0;
                inf.nu_profile_id=tempArray.getString(k);
            Log.d(TAG,"subcribers "+ inf.nu_profile_id);
                inf.nu_profile_name=tempArray.getString(++k);
                Log.d(TAG,"subcribers "+ inf.nu_profile_name);
                inf.nu_country=tempArray.getString(++k);               
                Log.d(TAG,"subcribers "+ inf.nu_country);
                JSONArray tempArray2 =tempArray.getJSONArray(++k);
                for( int j=0; j<tempArray2.length(); j++){
                    JSONArray tempArray21 =tempArray2.getJSONArray(j);
                    int l=0;
                    service=new Service1();
                    service.service_id = tempArray21.getString(l);
                    Log.e("service.service_id",""+service.service_id);
                    service.service_name= tempArray21.getString(++l);
                    service.payment_timestamp=tempArray21.getString(++l);
                    service.service_charge = tempArray21.getString(++l);
                    Log.e("service_charge",""+service.service_charge);


                    service.sub_validity=tempArray21.getString(++l);
                    Log.e("service.sub_validity",""+service.sub_validity);
                    servicesList.add(service);
                    inf.serviceList=servicesList;
                }


                mMysubscriber.add(inf);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return mMysubscriber;   
    }




    /**
     *  method to parse ServiceProvider details  coming from server
     *
     */

    public static ArrayList<ServiceProvider> parseSPList(String jsonString) {
        mProlist = new ArrayList<ServiceProvider>();
        try {

            int noOfUserComments;
            int noOfPhnos;
            int noOfServices;
            JSONObject jObject = new JSONObject(jsonString);


            JSONArray menuitemArray1 = jObject.getJSONArray("ProfilesList");
            /*
            {"ProfilesList":[["2002_chakri_edu","Chakrapani","Chakrapani provides technical guidance for
             CSE Students","India","hyderabad","4","0","1",[[null]],[["7001","100.0","Teaches Computer
             Engineering Subjects","Computer Engineering by Chakri"]]],["2005_rajesh_edu","Rajesh K","
             Rajesh provides services under CSE","india","hyderabad","4","0","1",[[null]],[["7003","100.0",
             "Teaches Programming Languagues","Programming Languagu"]]],["2006_madhuri_edu","Madhuri K",
             "Madhuri provides CSE related services","india","hyderabad","4","0","1",
            [[null]],[["7006","75.0","This course gives an introduction to data structures","Data structures"]]]]}
             */
            Log.d(TAG,""+menuitemArray1.length());
            UserComments userComments;
            Phnos pHno;
            ArrayList<UserComments> usercommentsList=new ArrayList<UserComments>();
            ArrayList<Phnos> PhnosList=new ArrayList<Phnos>();
            Service1 service;
            ArrayList<Service1> servicesList=new ArrayList<Service1>();

            for(int i=0 ;i<menuitemArray1.length();i++){
                ServiceProvider pfl=new ServiceProvider();
                JSONArray tempArray = menuitemArray1.getJSONArray(i);
                Log.e(TAG,"menuitemArray1 size "+menuitemArray1.length());
                Log.e(TAG,"tempArray.length() "+tempArray.length());
                int j=0;
                int k=0;
                Log.d(TAG,"spdetails "+ tempArray.getString(k));
                Log.d(TAG,"spdetails "+  tempArray.getString(++k));
                Log.d(TAG,"spdetails "+  tempArray.getString(++k));
                Log.d(TAG,"spdetails "+  tempArray.getString(++k));
                Log.d(TAG,"spdetails "+  tempArray.getString(++k));
                Log.d(TAG,"spdetails "+  tempArray.getString(++k));
                Log.d(TAG,"spdetails "+  tempArray.getString(++k));
                Log.d(TAG,"spdetails "+  tempArray.getString(++k));
                Log.d(TAG,"spdetails "+  tempArray.getString(++k));

                k=0;
                pfl.profile_id=tempArray.getString(k);
                pfl.profile_name=tempArray.getString(++k);
                pfl.profile_des=tempArray.getString(++k);
                pfl.country=tempArray.getString(++k);
                pfl.city=tempArray.getString(++k);
                pfl.rating=tempArray.getString(++k);
                pfl.is_online=tempArray.getString(++k);
                pfl.is_service_provider=tempArray.getString(++k);
                pfl.profile_pic_url=tempArray.getString(++k);
                JSONArray tempArray1 =tempArray.getJSONArray(++k);

                for( j=0; j<tempArray1.length(); j++){
                    JSONArray tempArray11 =tempArray1.getJSONArray(j);
                    userComments=new UserComments();
                    int l=0;
                    userComments=new UserComments();
                    userComments.userComments = tempArray11.getString(l);
                    Log.e(TAG,"userComments.userComments "+userComments.userComments);
                    userComments.name=tempArray11.getString(++l);
                    Log.e(TAG,"userComments.name "+userComments.name);
                    userComments.sp_profileid=pfl.profile_id;
                    Log.e(TAG,"userComments.id "+pfl.profile_id);
                    usercommentsList.add( userComments);

                }

                JSONArray tempArray2 =tempArray.getJSONArray(++k);
                for( j=0; j<tempArray2.length(); j++){
                    JSONArray tempArray21 =tempArray2.getJSONArray(j);
                    int l=0;
                    service=new Service1();
                    service.service_id = tempArray21.getString(l);
                    Log.e(TAG,"service.service_id "+service.service_id);
                    service.service_charge = tempArray21.getString(++l);
                    Log.e(TAG,"service_charge "+service.service_charge);
                    service.service_name= tempArray21.getString(++l);
                    service.service_des= tempArray21.getString(++l);
                    servicesList.add(service);
                }
                pfl.usercommentsList=usercommentsList;
                pfl.phnoList=PhnosList;
                pfl.serviceList=servicesList;
                mProlist.add(pfl);

            }


        } catch (JSONException e) {
            e.printStackTrace();
        }

        return mProlist;
    }