java android write to sd card

You can access to sd card by File sdCard = Environment.getExternalStorageDirectory();
Note : Hard coding the /sdcard/ folder is not good.


Write to sd card

File sdCard = Environment.getExternalStorageDirectory();
File dir = new File (sdcard.getAbsolutePath() + "/dir1/dir2");
dir.mkdirs();
File file = new File(dir, "filename");
FileOutputStream f = new FileOutputStream(file);
...

And read/write to file   by using FileOutputStream f .

No comments :

Post a Comment

Your Comment and Question will help to make this blog better...