Q:

getting images saved in null folder : Android

String gender;   

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}
    mTextureView = (TextureView) findViewById(R.id.textureView1);
    mTextureView.setSurfaceTextureListener(this);

    final Button buttonStartCameraPreview = (Button)findViewById(R.id.startcamerapreview);
    final Button buttonCapturePreview = (Button)findViewById(R.id. Capturecamerapreview);

    rgGender = (RadioGroup) findViewById(R.id.rgGender);
    rdbMale = (RadioButton) findViewById(R.id.rdbMale);
    rdbFemale = (RadioButton) findViewById(R.id.rdbFemale);

    PatientInfo = (EditText) findViewById(R.id. PatientName);
    PatientInfo.setHint("Enter patient name");
    PatientAge = (EditText) findViewById(R.id. Age);
    PatientAge.setHint("Age");
    PatientId = (EditText) findViewById(R.id. PatientId);
    PatientId.setHint("Enter patient Id no:");

    rawCallback = new PictureCallback() 
    {
        public void onPictureTaken(byte[] data, Camera camera)
        {
            Log.d("Log", "onPictureTaken - raw");
        }
    };

    shutterCallback = new ShutterCallback()
    {
        public void onShutter() {
            Log.i("Log", "onShutter'd");
        }
    };

    jpegCallback = new PictureCallback()
    {

        @Override
        public void onPictureTaken(byte[] data, Camera mCamera) 
        {
            int imageNum = 0;
            String Name = PatientInfo.getText().toString();
            String Age =  PatientAge.getText().toString();
            String Id = PatientId.getText().toString();

            Intent imageIntent = new Intent(android.provider. MediaStore. ACTION_IMAGE_CAPTURE);
            Date d = new Date();
            CharSequence s  = DateFormat.format("MM-dd-yy hh-mm-ss", d.getTime());

            Rname = "Raw"+s.toString() + "_img_"+ String.valueOf(imageNum)+".jpg";
            Pname = "Proc"+s.toString()+ "_img_"+ String.valueOf(imageNum) +".jpg";

            File imagesFolders = new File(Environment.getExternalStorageDirectory().toString() + "/" + Name + Age + gender +Id);

            imagesFolders.mkdirs();
            File output = new File(imagesFolders, Rname);

            while (output.exists()){
                imageNum++;
                Rname = "Raw"+s.toString() + "_img_"+ String.valueOf(imageNum) +".jpg";
                Pname = "Proc"+s.toString() + "_img_"+ String.valueOf(imageNum) +".jpg";
                output = new File(imagesFolders, Rname);
            }

            callname ="/sdcard/"+ Name + Age + gender + Id +"/"+ Rname;
            Uri uriSavedImage = Uri.fromFile(output);
            imageIntent.putExtra(MediaStore. EXTRA_OUTPUT, uriSavedImage);
            OutputStream imageFileOS;

            try {

                imageFileOS = getContentResolver().openOutputStream(uriSavedImage);
                imageFileOS.write(data);
                imageFileOS.flush();
                imageFileOS.close();        } 
            catch (FileNotFoundException e) 
                {
                e.printStackTrace();
                } 
            catch (IOException e)
            {
                e.printStackTrace();

            } 
            finally
            {}
            Log.d("Log", "onPictureTaken - jpeg");
       }

             public void onRadioButtonClicked(View view) {

        boolean checked = ((RadioButton) view).isChecked();
        switch(view.getId()) 
        {
            case R.id.rdbMale:
                if (checked)
                    gender= "M";
                rdbFemale.setChecked(false);

                break;
            case R.id.rdbFemale:
                if (checked)
                    gender = "F";

                rdbMale.setChecked(false);

                break;
        }
        }

This is a piece of code.  Am trying to save the images in the folder after enter the details like name, age, gender.  but if i am not entering any thing and just take the image it will save the image into a null folder.  I dont want this to happen.  When details are not entered it should not save the image any where and it should show a message like please enter the data.  Can anyone help why it is saving the data yo a null folder

A:

Use Validation bro. 
if (edt.getText().toString().length() <= 0) {
    edt.setError("Please Enter Name/Name Required."); 
    valid_name = null;
} else if (! edt.getText().toString().matches("[a-zA-Z ]+")) {
    edt.setError("Accept Alphabets Only."); 
    valid_name = null;
} else {
    valid_name = edt.getText().toString();
}

or refer this site:
http://chintankhetiya.wordpress.com/2013/05/29/edit-text-validation/

