Cukup simpel caranya membuat sebuah folder di Android, gunakan saja script berikut.
File folder = new File(Environment.getExternalStorageDirectory() + "/NewFolder");
boolean success = true;
if (!folder.exists()) {
success = folder.mkdir();
}
if (success) {
// Do something on success
Toast.makeText(getApplicationContext(), "Folder created", Toast.LENGTH_SHORT).show();
} else {
// Do something else on failure
Toast.makeText(getApplicationContext(), "Failed", Toast.LENGTH_SHORT).show();
}
Jangan lupa tambahkan permision di AndroidManifiest.xml
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
Semoga Bermanfaat.
No comments:
Post a Comment
Silahkan