Can we not simply create new directory programmatically on external SD card (not internal memory of device) in Android and can we not write files on SD card?
Is Titanium
You can use System
class to get storage variables like below
To get the internal SD card you can use
String extStore = System.getenv("EXTERNAL_STORAGE");
File f_exts = new File(extStore);
To get the external SD card you can use
String secStore = System.getenv("SECONDARY_STORAGE");
File f_secs = new File(secStore);
You can choose where to create folder and which one to use.
EDIT
Environment.getExternalStorageDirectory()
DetailsNote: don't be confused by the word "external" here. This directory can better be thought as media/shared storage. It is a filesystem that can hold a relatively large amount of data and that is shared across all applications (does not enforce permissions). Traditionally this is an SD card, but it may also be implemented as built-in storage in a device that is distinct from the protected internal storage and can be mounted as a filesystem on a computer.
Reference from Environment
Hope it'll help.
try this create folder and file in sdcard
File localFile = new File(Environment.getExternalStorageDirectory(),"/data/create_new_folder_name/");
if (!localFile.exists()) {
localFile.mkdir();
}
try{
File gpxfile = new File(localFile, "yourfilename.xyz");
FileWriter writer = new FileWriter(gpxfile,true);
writer.append("your file text");
writer.flush();
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
manifest.xml permission
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Use the Storage Access Framework to write on the micro SD card. Google for ACTION_OPEN_DOCUMENT_TREE and ACTION_OPEN_DOCUMENT.
Besides that you can write in a normal way in one app specific directory on the micro SD card. Have a look at the second entry returned by getExternalFilesDirs().