I was developing an app and needed to create a folder inside SD card when button is onClick.
I have no idea how to do it. Anyone can help ? Please.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_date_select);
edit_date = (EditText) findViewById(R.id.edit_date);
edit_date.setGravity(Gravity.CENTER_HORIZONTAL);
btn_setDate = (Button) findViewById(R.id.btn_setDate);
btn_setDate.setOnClickListener(this);
updateDate();
btn_cFolder = (Button) findViewById(R.id.btn_cFolder);
btn_cFolder.setOnClickListener(new OnClickListener() {
public void onClick(View v)
{
Environment.getExternalStorageDirectory();
File folder = new File(Environment.getExternalStorageDirectory() + "/wahaha");
boolean success = true;
if (!folder.exists()) {
success = folder.mkdir();
}
if (success) {
Toast.makeText(getBaseContext(), "You have successfully created." , Toast.LENGTH_LONG ).show();
} else {
Toast.makeText(getBaseContext(), "You have Failed to create." , Toast.LENGTH_LONG ).show();
}
}
});
}
I'm beginner of android develop.
okay i now have doing many of research and i found out the folder are able to see on the android device. But once i plugged into PC . still not able to see. Any suggestion see the folder on PC?
And by the way why it save to internal storage ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…