Identifying which previous activity is calling current activity and decide which data to fetch
<p>I have a situation as stated below.</p>

<p>Activity A can call B or D.</p>

<p>B calls C, after input details into C, and press back, C will pass data back to B. From B, if I select either row, the row will bring me to D.</p>

<p>Now, my problem is, from D, i want to set if-else statement to know which StartActivityForResult from B is calling D, so that I can send respective data from C to B and to D.</p>

<pre><code>       _____&gt;B------&gt;C
      /      |
A----&gt;       |(B can call D and pass data from selected row from B to D.)
      \_____&gt;D
</code></pre>

<p>Code ACTIVITY D:</p>

<pre><code>    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);     
        setContentView(R.layout.tab_content_setting);
        this.initViews();
        bluguard = BluGuardProtocol.getInstance();
    }

    private void initViews(){
        mainActivity = (BluGuardProto2Activity) this.getParent();
        toolbar = (ToolBar)mainActivity.findViewById(R.id.toolbar);
        etAccountName = (EditText)this.findViewById(R.id.etAccountName);
        etWanIp = (EditText)this.findViewById(R.id.etWanIp);
        etLocalIp = (EditText)this.findViewById(R.id.etLocalIp);
        etPort = (EditText)this.findViewById(R.id.etPort);
        etPassword = (EditText)this.findViewById(R.id.etPassword);
        switcher = (ViewSwitcher)this.findViewById(R.id.switcher);
        infoView = (RelativeLayout)this.findViewById(R.id.infoView);
        btnConnection = (Button)this.findViewById(R.id.btnConnection);

        btnConnection.setOnClickListener(new OnClickListener(){
            @Override
            public void onClick(View arg0) {
                if(bluguard.isLoggedInAndConnected()){
                    toolbar.disconnect();
                    btnConnection.setText(getResources().getString(R.string.connect));} else {
                    toolbar.connect();}}});

                // Assigns value
    String choice = getIntent().getStringExtra("activity");
    //Bundle extras = intent.getExtras();
    SharedPreferences  sp = PreferenceManager.getDefaultSharedPreferences(this);
    if(choice != null &amp;&amp; choice.equals("activity2")) {
    //if(extras.contains("activity2")){
    etAccountName.setText(sp.getString("accountName2", ""));
    etWanIp.setText(sp.getString("wanIp2", ""));
    etLocalIp.setText(sp.getString("localIp2", ""));
    etPort.setText(sp.getString("port2", ""));
    etPassword.setText(sp.getString("password2", ""));}
    }

    @Override
    protected void onResume() {
        super.onResume();
        this.toolbar.setProtocolCallback(this);
        this.toolbar.setRightButtonDrawable(R.drawable.ic_btn_info);
        this.toolbar.setRightButtonOnClickListener(new OnClickListener(){
            @Override
            public void onClick(View arg0) {
                showInfoView();}});

        this.toolbar.setLeftButtonOnClickListener(new OnClickListener(){
            @Override
            public void onClick(View arg0) {
                if(bluguard.isLoggedInAndConnected()){
                    toolbar.disconnect();} else {
                    toolbar.connect();}}});

        if(bluguard.isLoggedInAndConnected()){
            btnConnection.setText(getResources().getString(R.string.disconnect));
        } else {
            btnConnection.setText(getResources().getString(R.string.connect));}}

    private void showInfoView(){
        mainActivity.hideTabs();

        this.toolbar.setRightButtonDrawable(0);
        this.toolbar.setRightButtonOnClickListener(null);
        this.toolbar.setLeftButtonDrawable(R.drawable.ic_btn_back);
        this.toolbar.setLeftButtonOnClickListener(new OnClickListener(){
            @Override
            public void onClick(View v) {
                showSettingsView();
            }
        });
        this.toolbar.setText(getResources().getString(R.string.about));

        switcher.showNext();
    }

    private void showSettingsView(){
        this.toolbar.initConnectionUI();
        this.toolbar.setRightButtonDrawable(R.drawable.ic_btn_info);
        this.toolbar.setRightButtonOnClickListener(new OnClickListener(){
            @Override
            public void onClick(View arg0) {
                showInfoView();
            }
        });
        mainActivity.showTabs();
        switcher.showPrevious();
    }

    @Override
    protected void onPause() {
        super.onPause();
    }

    @Override
    public void onBackPressed() {
        Intent i = new Intent(SettingActivity.this, WelcomeActivity.class);
        startActivity(i);
        finish();
        super.onBackPressed();
    }

    @Override
    public void onLoginCompleted(boolean succeeded, int code) {
        if(succeeded){
            btnConnection.setText(getResources().getString(R.string.disconnect));
        }
    }

    @Override
    public void onToggleAlarmCompleted(boolean succeeded, int code) {
        // Do nothing
    }

    @Override
    public void onToggleHACompleted(boolean succeeded, int code) {
        // Do nothing
    }

    @Override
    public void onStatusPollCompleted(AlarmStatus status) {
        // Do nothing}

    @Override
    public void onDisconnected() {
        btnConnection.setText(getResources().getString(R.string.connect));}

    @Override
    public void onRequestTimedOut(TimeOutType type) {
        // Do nothing}

    @Override
    public void onPreReconnect() {
        InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(), 0);}}
</code></pre>

<p>Code ACTIVITY B:</p>

<pre><code> public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.account_main);
        this.initViews();

        //Set onClick on Button Add
        Button btnAdd = (Button)findViewById(R.id.btnAdd);        
        btnAdd.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                if (tableRow1.getVisibility() == (View.GONE)){
                    tableRow1.setVisibility(View.VISIBLE);
                    border1.setVisibility(View.VISIBLE);}
                else if (tableRow2.getVisibility() == (View.GONE)){
                        tableRow2.setVisibility(View.VISIBLE);
                        border2.setVisibility(View.VISIBLE);}
                else if (tableRow3.getVisibility() == (View.GONE)){
                        tableRow3.setVisibility(View.VISIBLE);
                        border3.setVisibility(View.VISIBLE);}
                else if (tableRow4.getVisibility() == (View.GONE)){
                        tableRow4.setVisibility(View.VISIBLE);
                        border4.setVisibility(View.VISIBLE);}
                else if (tableRow5.getVisibility() == (View.GONE)){
                        tableRow5.setVisibility(View.VISIBLE);
                        border5.setVisibility(View.VISIBLE);}
                else if (tableRow6.getVisibility() == (View.GONE)){
                        tableRow6.setVisibility(View.VISIBLE);
                        border6.setVisibility(View.VISIBLE);}
                else if (tableRow7.getVisibility() == (View.GONE)){
                        tableRow7.setVisibility(View.VISIBLE);
                        border7.setVisibility(View.VISIBLE);}
                else if (tableRow8.getVisibility() == (View.GONE)){
                        tableRow8.setVisibility(View.VISIBLE);
                        border8.setVisibility(View.VISIBLE);}
                else if (tableRow9.getVisibility() == (View.GONE)){
                        tableRow9.setVisibility(View.VISIBLE);
                        border9.setVisibility(View.VISIBLE);}
                else if (tableRow10.getVisibility() == (View.GONE)){
                        tableRow10.setVisibility(View.VISIBLE);
                        border10.setVisibility(View.VISIBLE);}
                else {
                        final AlertDialog alertDialog = new AlertDialog.Builder(AccountSetup.this).create();
                        alertDialog.setTitle("Alert Message");
                        alertDialog.setMessage("You have reached the maximum number of users");
                        alertDialog.setIcon(R.drawable.icon_tick);
                        alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                            }
                        });
                        alertDialog.show();
                    }   
        }});
    }

    private void initViews(){ 
        //Account 1  
        tableRow1  = (TableRow)findViewById(R.id.tableRow1);
        border1    = (View)findViewById(R.id.border1);
        iconNext1  = (Button)findViewById(R.id.iconNext1);
        tableRow1.setOnLongClickListener(new OnLongClickListener() {
            public boolean onLongClick(View v) {
            AlertDialog.Builder alertDialog = new AlertDialog.Builder(AccountSetup.this);
            alertDialog.setTitle("User Account Deletion");
            alertDialog.setMessage("Are you sure to delete this user account?");
            alertDialog.setIcon(R.drawable.icon_alert);
            alertDialog.setPositiveButton("YES", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog,int which) {
                    tableRow1.setVisibility(View.GONE);
                    border1.setVisibility(View.GONE);}});
            alertDialog.setNegativeButton("NO", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();}});
            alertDialog.show();
            return true;
            }});
        tableRow1.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
                /*tableRow1.setEnabled(true);
                tableRow1.setSelected(true);
                tableRow1.requestFocusFromTouch();*/
                Intent Intent1 = new Intent(AccountSetup.this, BluGuardProto2Activity.class);
                Intent1.putExtra("activity", "activity1");
                startActivityForResult(Intent1, 150);
                }
        });          
        iconNext1.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Intent Intent1 = new Intent(AccountSetup.this, AccountSettingActivity1.class);
            startActivityForResult(Intent1, 100);}});

        //Account 2
        tableRow2  = (TableRow)findViewById(R.id.tableRow2);  
        border2    = (View)findViewById(R.id.border2);
        iconNext2  = (Button)findViewById(R.id.iconNext2);
        tableRow2.setOnLongClickListener(new OnLongClickListener() {
        public boolean onLongClick(View v) {
            AlertDialog.Builder alertDialog = new AlertDialog.Builder(AccountSetup.this);
            alertDialog.setTitle("User Account Deletion");
            alertDialog.setMessage("Are you sure to delete this user account?");
            alertDialog.setIcon(R.drawable.icon_alert);
            alertDialog.setPositiveButton("YES", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog,int which) {
                tableRow2.setVisibility(View.GONE);
                border2.setVisibility(View.GONE);}});
            alertDialog.setNegativeButton("NO", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.cancel();}});
            alertDialog.show();
            return true;}});
        tableRow2.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                    /*tableRow1.setEnabled(true);
                    tableRow1.setSelected(true);
                    tableRow1.requestFocusFromTouch();*/
                    Intent Intent2 = new Intent(AccountSetup.this, BluGuardProto2Activity.class);
                    Intent2.putExtra("activity", "activity2");
                    startActivityForResult(Intent2, 250);
                    }
            });
        iconNext2.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Intent Intent2 = new Intent(AccountSetup.this, AccountSettingActivity2.class);
            startActivityForResult(Intent2, 200);}});

        //Account 3
        tableRow3  = (TableRow)findViewById(R.id.tableRow3);  
        border3    = (View)findViewById(R.id.border3);
        iconNext3  = (Button)findViewById(R.id.iconNext3); 
        tableRow3.setOnLongClickListener(new OnLongClickListener() {
        public boolean onLongClick(View v) {
            AlertDialog.Builder alertDialog = new AlertDialog.Builder(AccountSetup.this);
            alertDialog.setTitle("User Account Deletion");
            alertDialog.setMessage("Are you sure to delete this user account?");
            alertDialog.setIcon(R.drawable.icon_alert);
            alertDialog.setPositiveButton("YES", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog,int which) {
                tableRow3.setVisibility(View.GONE);
                border3.setVisibility(View.GONE);}});
            alertDialog.setNegativeButton("NO", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.cancel();}});
            alertDialog.show();
            return true;}});   
        iconNext3.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
            Intent Intent3 = new Intent(AccountSetup.this, AccountSettingActivity3.class);
            startActivityForResult(Intent3, 300);}});

        //Account 4
        tableRow4  = (TableRow)findViewById(R.id.tableRow4);  
        border4    = (View)findViewById(R.id.border4);
        iconNext4  = (Button)findViewById(R.id.iconNext4); 
        tableRow4.setOnLongClickListener(new OnLongClickListener() {
        public boolean onLongClick(View v) {
            AlertDialog.Builder alertDialog = new AlertDialog.Builder(AccountSetup.this);
            alertDialog.setTitle("User Account Deletion");
            alertDialog.setMessage("Are you sure to delete this user account?");
            alertDialog.setIcon(R.drawable.icon_alert);
            alertDialog.setPositiveButton("YES", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog,int which) {
                tableRow4.setVisibility(View.GONE);
                border4.setVisibility(View.GONE);}});
            alertDialog.setNegativeButton("NO", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.cancel();}});
            alertDialog.show();
            return true;}});              
        iconNext4.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Intent Intent4 = new Intent(AccountSetup.this, AccountSettingActivity4.class);
            startActivityForResult(Intent4, 400);}});

        //Account 5
        tableRow5  = (TableRow)findViewById(R.id.tableRow5);  
        border5    = (View)findViewById(R.id.border5);
        iconNext5  = (Button)findViewById(R.id.iconNext5); 
        tableRow5.setOnLongClickListener(new OnLongClickListener() {
            public boolean onLongClick(View v) {
            AlertDialog.Builder alertDialog = new AlertDialog.Builder(AccountSetup.this);
            alertDialog.setTitle("User Account Deletion");
            alertDialog.setMessage("Are you sure to delete this user account?");
            alertDialog.setIcon(R.drawable.icon_alert);
            alertDialog.setPositiveButton("YES", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog,int which) {
                tableRow5.setVisibility(View.GONE);
                border5.setVisibility(View.GONE);}});
            alertDialog.setNegativeButton("NO", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.cancel();}});
            alertDialog.show();
            return true;}});
        iconNext5.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Intent Intent5 = new Intent(AccountSetup.this, AccountSettingActivity5.class);

            startActivityForResult(Intent5, 500);}});

        //Account 6
        tableRow6  = (TableRow)findViewById(R.id.tableRow6);  
        border6    = (View)findViewById(R.id.border6); 
        iconNext6  = (Button)findViewById(R.id.iconNext6); 
        tableRow6.setOnLongClickListener(new OnLongClickListener() {
        public boolean onLongClick(View v) {
            AlertDialog.Builder alertDialog = new AlertDialog.Builder(AccountSetup.this);
            alertDialog.setTitle("User Account Deletion");
            alertDialog.setMessage("Are you sure to delete this user account?");
            alertDialog.setIcon(R.drawable.icon_alert);
            alertDialog.setPositiveButton("YES", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog,int which) {
                tableRow6.setVisibility(View.GONE);
                border6.setVisibility(View.GONE);}});
            alertDialog.setNegativeButton("NO", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.cancel();}});
            alertDialog.show();
            return true;}});    
        iconNext6.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Intent Intent6 = new Intent(AccountSetup.this, AccountSettingActivity6.class);
            startActivityForResult(Intent6, 600);}});

        //Account 7
        tableRow7  = (TableRow)findViewById(R.id.tableRow7);  
        border7    = (View)findViewById(R.id.border7); 
        iconNext7  = (Button)findViewById(R.id.iconNext7);
        tableRow7.setOnLongClickListener(new OnLongClickListener() {
        public boolean onLongClick(View v) {
            AlertDialog.Builder alertDialog = new AlertDialog.Builder(AccountSetup.this);
            alertDialog.setTitle("User Account Deletion");
            alertDialog.setMessage("Are you sure to delete this user account?");
            alertDialog.setIcon(R.drawable.icon_alert);
            alertDialog.setPositiveButton("YES", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog,int which) {
                tableRow7.setVisibility(View.GONE);
                border7.setVisibility(View.GONE);}});
            alertDialog.setNegativeButton("NO", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.cancel();}});
            alertDialog.show();
            return true;}});    
        iconNext7.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Intent Intent7 = new Intent(AccountSetup.this, AccountSettingActivity7.class);
            startActivityForResult(Intent7, 700);}});

        //Account 8
        tableRow8  = (TableRow)findViewById(R.id.tableRow8);  
        border8    = (View)findViewById(R.id.border8);  
        iconNext8  = (Button)findViewById(R.id.iconNext8);
        tableRow8.setOnLongClickListener(new OnLongClickListener() {
        public boolean onLongClick(View v) {
            AlertDialog.Builder alertDialog = new AlertDialog.Builder(AccountSetup.this);
            alertDialog.setTitle("User Account Deletion");
            alertDialog.setMessage("Are you sure to delete this user account?");
            alertDialog.setIcon(R.drawable.icon_alert);
            alertDialog.setPositiveButton("YES", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog,int which) {
                tableRow8.setVisibility(View.GONE);
                border8.setVisibility(View.GONE);}});
            alertDialog.setNegativeButton("NO", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.cancel();}});
            alertDialog.show();
            return true;}});    
        iconNext8.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Intent Intent8 = new Intent(AccountSetup.this, AccountSettingActivity8.class);
            startActivityForResult(Intent8, 800);}});

        //Account 9
        tableRow9  = (TableRow)findViewById(R.id.tableRow9);  
        border9    = (View)findViewById(R.id.border9);  
        iconNext9  = (Button)findViewById(R.id.iconNext9);
        tableRow9.setOnLongClickListener(new OnLongClickListener() {
        public boolean onLongClick(View v) {
            AlertDialog.Builder alertDialog = new AlertDialog.Builder(AccountSetup.this);
            alertDialog.setTitle("User Account Deletion");
            alertDialog.setMessage("Are you sure to delete this user account?");
            alertDialog.setIcon(R.drawable.icon_alert);
            alertDialog.setPositiveButton("YES", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog,int which) {
                tableRow9.setVisibility(View.GONE);
                border9.setVisibility(View.GONE);}});
            alertDialog.setNegativeButton("NO", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.cancel();}});
            alertDialog.show();
            return true;}});     
        iconNext9.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Intent Intent9 = new Intent(AccountSetup.this, AccountSettingActivity9.class);
            startActivityForResult(Intent9, 900);}});

        //Account 10
        tableRow10  = (TableRow)findViewById(R.id.tableRow10);  
        border10    = (View)findViewById(R.id.border10);
        iconNext10  = (Button)findViewById(R.id.iconNext10);
        tableRow10.setOnLongClickListener(new OnLongClickListener() {
        public boolean onLongClick(View v) {
            AlertDialog.Builder alertDialog = new AlertDialog.Builder(AccountSetup.this);
            alertDialog.setTitle("User Account Deletion");
            alertDialog.setMessage("Are you sure to delete this user account?");
            alertDialog.setIcon(R.drawable.icon_alert);
            alertDialog.setPositiveButton("YES", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog,int which) {
                    tableRow10.setVisibility(View.GONE);
                    border10.setVisibility(View.GONE);}});
            alertDialog.setNegativeButton("NO", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();}});
            alertDialog.show();
            return true;}});      
        iconNext10.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Intent Intent10 = new Intent(AccountSetup.this, AccountSettingActivity10.class);
            startActivityForResult(Intent10, 1000);}});
    }

    public void onBackPressed() {
        Intent i = new Intent(AccountSetup.this, WelcomeActivity.class);
        startActivity(i);
        finish();
        super.onBackPressed();
    }

    @Override
    protected void onActivityResult(int requestCode,int resultCode, Intent data) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
       if (requestCode == 100) {
           data.getStringExtra("accountName1");  
           data.getStringExtra("wanIp1");
           data.getStringExtra("localIp1");
           data.getStringExtra("port1");
           data.getStringExtra("password1");
           if (resultCode == RESULT_OK) {      
               TextView user1 = (TextView)findViewById(R.id.user1);  
               user1.setText(sp.getString("accountName1", ""));}}

       else if ((requestCode == 150)&amp;&amp;(resultCode == RESULT_OK)) {
           data.getStringExtra("accountName1");  
           data.getStringExtra("wanIp1");
           data.getStringExtra("localIp1");
           data.getStringExtra("port1");
           data.getStringExtra("password1");}

       else if (requestCode == 200) {
           if (resultCode == RESULT_OK) {      
               data.getStringExtra("accountName2");   
               TextView user2 = (TextView)findViewById(R.id.user2);  
               user2.setText(sp.getString("accountName2", ""));}}

       else if ((requestCode == 250)&amp;&amp;(resultCode == RESULT_OK)) {
           data.getStringExtra("accountName2");  
           data.getStringExtra("wanIp2");
           data.getStringExtra("localIp2");
           data.getStringExtra("port2");
           data.getStringExtra("password2");}

       else if (requestCode == 300) {
           if (resultCode == RESULT_OK) {      
               data.getStringExtra("accountName3");   
               TextView user3 = (TextView)findViewById(R.id.user3);  
               user3.setText(sp.getString("accountName3", ""));
           }
       }
       else if (requestCode == 400) {
           if (resultCode == RESULT_OK) {      
               data.getStringExtra("accountName4");   
               TextView user4 = (TextView)findViewById(R.id.user4);  
               user4.setText(sp.getString("accountName4", ""));
           }
       }
       else if (requestCode == 500) {
           if (resultCode == RESULT_OK) {      
               data.getStringExtra("accountName5");   
               TextView user5  = (TextView)findViewById(R.id.user5);  
               user5.setText(sp.getString("accountName5", ""));
           }
       }
       else if (requestCode == 600) {
           if (resultCode == RESULT_OK) {      
               data.getStringExtra("accountName6");   
               TextView user6 = (TextView)findViewById(R.id.user6);  
               user6.setText(sp.getString("accountName6", ""));
           }
       }
       else if (requestCode == 700) {
           if (resultCode == RESULT_OK) {      
               data.getStringExtra("accountName7");   
               TextView user7 = (TextView)findViewById(R.id.user7);  
               user7.setText(sp.getString("accountName7", ""));
           }
       }
       else if (requestCode == 800) {
           if (resultCode == RESULT_OK) {      
               data.getStringExtra("accountName8");   
               TextView user8 = (TextView)findViewById(R.id.user8);  
               user8.setText(sp.getString("accountName8", ""));
           }
       }
       else if (requestCode == 900) {
           if (resultCode == RESULT_OK) {      
               data.getStringExtra("accountName9");   
               TextView user9 = (TextView)findViewById(R.id.user9);  
               user9.setText(sp.getString("accountName9", ""));
           }
       }
       else if (requestCode == 1000) {
           if (resultCode == RESULT_OK) {      
               data.getStringExtra("accountName10");   
               TextView user10 = (TextView)findViewById(R.id.user10);  
               user10.setText(sp.getString("accountName10", ""));
           }
       }
    }
}
</code></pre>

<p>Below is the snippet of code that use to start D from row-click in B since the code is long, so I try to make it clearer~</p>

<pre><code>tableRow1.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
                Intent Intent1 = new Intent(AccountSetup.this, BluGuardProto2Activity.class);
                Intent1.putExtra("activity", "activity1");
                startActivityForResult(Intent1, 150);}});
</code></pre>

<p>Snippet of Activity D:</p>

<pre><code>// Assigns value
String choice = getIntent().getStringExtra("activity");
//Bundle extras = intent.getExtras();
SharedPreferences  sp = PreferenceManager.getDefaultSharedPreferences(this);
if(choice != null &amp;&amp; choice.equals("activity2")) {
//if(extras.contains("activity2")){
etAccountName.setText(sp.getString("accountName2", ""));
etWanIp.setText(sp.getString("wanIp2", ""));
etLocalIp.setText(sp.getString("localIp2", ""));
etPort.setText(sp.getString("port2", ""));
etPassword.setText(sp.getString("password2", ""));}
}
</code></pre>
