-3

Guys I'm working on android , and i have a static variable , lets say "var" , if it's null then if statement is executed or else is executed , the thing is , even after i "var" is not null , if i restart tab it works as expected , someone enlighten me .

**protected static String ipath="" , ipath1;**


 protected OnClickListener selimg = new OnClickListener() // for first image
{

    @Override
    public void onClick(View vw) 
    {
        // TODO Auto-generated method stub
        Intent i = new Intent(
                Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI);
                 startActivityForResult(i, RESULT_LOAD_IMAGE);

    }



};

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK && null != data) {
        Uri selectedImage = data.getData();
        String[] filePathColumn = { MediaStore.Images.Media.DATA };

        Cursor cursor = getContentResolver().query(selectedImage,
                filePathColumn, null, null, null);
        cursor.moveToFirst();

        int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
        String picturePath = cursor.getString(columnIndex);
        cursor.close();
        ImageView imageView = (ImageView) findViewById(R.id.imageView1);
        ImageView imageView1 = (ImageView) findViewById(R.id.imageView2);
        **if(ipath == "")
        {
        ipath=picturePath;

        imageView.setImageBitmap(BitmapFactory.decodeFile(picturePath));
        }
        else
        {
            ipath1=picturePath;
            imageView1.setImageBitmap(BitmapFactory.decodeFile(picturePath));

        }**

    }
}
Joel Christophel
  • 2,496
  • 4
  • 28
  • 48
Rakesh Bk
  • 94
  • 13

1 Answers1

0

Change if(ipath == "") to if(ipath.isEmpty()) or you can also change it to if(ipath.equals("")) and I suggest reading This

Community
  • 1
  • 1
Prateek
  • 1,876
  • 1
  • 11
  • 22
  • Guys i figured it out , i had to use onDestroy() method ,so that resourced are cleaned before quitting !!!! – Rakesh Bk Sep 24 '13 at 17:54