First, you will need to add the appropriate permission to your AndroidManifest.xml file:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
You will also want to check (at runtime) if the device running your application has available external storage:
String state = Environment.getExternalStorageState();
if(Environment.MEDIA_MOUNTED.equals(state))
{
// Read / Write Access
externalStorageAvailable = true;
externalStorageWriteable = true;
}
else if(Environment.MEDIA_MOUNTED_READ_ONLY.equals(state))
{
// Read Access
externalStorageAvailable = true;
externalStorageWriteable = false;
}
else
{
// We cannot read / write
externalStorageAvailable = false;
externalStorageWriteable = false;
}
Finally, you can write the file by doing something like the following...
FileOutputStream fileStream = null;
PrintStream printStream = null;
File file = new File(FILE_NAME);
try
{
fileStream = new FileOutputStream(file);
printStream = new PrintStream(fileStream);
for (int i = 0; i < FLOAT_ARRAY_SIZE; i++)
{
printStream.print(FLOAT_DATA[i]);
printStream.println();
}
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
if(printStream != null)
{
printStream.close();
}
}
As stated before, a '.bin' or '.dat' extension is fine.