2

How do I add default image when create directory? This is my code below which create directory using alert dailog, but I want to add default image automaticallly if directory created, what do I do?

Deault image id is (R.drawable.myimage). I want to add this image in directory when directory is created.

AlertDialog.Builder alert = new AlertDialog.Builder(context);
alert.setTitle("Add New Photo Folder"); // Set Alert dialog

// title here
alert.setMessage("Enter Folder Name "); // Message here

// Set an EditText view to get user input
final EditText input = new EditText(context);
alert.setView(input);

alert.setPositiveButton("OK", new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int whichButton) {
        String srt = input.getEditableText().toString();
        Toast.makeText(context, srt, Toast.LENGTH_LONG).show();

        File photos = new
        File(getFilesDir(), srt);

        if (!photos.exists()) {
            photos.mkdirs();

            gridView.invalidateViews();
            gridView.setAdapter(simpleAdapter);

            inflateListView(currentFiles);
            finish();

            startActivity(getIntent());
        } else {
            Toast.makeText(context, "Already Exist This folder", Toast.LENGTH_LONG).show();
        }
    }
});

alert.setNegativeButton("CANCEL", new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int whichButton) {
        // Canceled.
        dialog.cancel();
    }
}); // End of alert.setNegativeButton

AlertDialog alertDialog = alert.create();
timss
  • 9,982
  • 4
  • 34
  • 56
hayya anam
  • 45
  • 6
  • `add default image automaticallly if directory create what do i do?` in which directory u want to add save image?. use Dir.isDirectory() and Dir.exists() before saving image to dir – ρяσѕρєя K May 02 '13 at 14:33
  • any directory which create like photos.mkdirs(); – hayya anam May 02 '13 at 14:35
  • please see [Save image to sdcard from drawble resource on Android](http://stackoverflow.com/questions/10558053/save-image-to-sdcard-from-drawble-resource-on-android) for saving drawable image to directory as default image. let ,me known if this help u – ρяσѕρєя K May 02 '13 at 14:40

0 Answers0