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));
}**
}
}