@Override public BufferedWriter openForWriting(String filename) throws IOException { Log.i(TAG, "Opening " + getDirectory() + "/" + filename + " for writing on external storage"); File externalStoragePath = Environment.getExternalStorageDirectory(); File directory = new File(externalStoragePath.getAbsolutePath() + "/" + getDirectory()); File file = new File(directory, filename); try { directory.mkdirs(); OutputStream outputStream = new FileOutputStream(file); return new BufferedWriter(new OutputStreamWriter(outputStream)); } catch(IOException e) { Log.w(TAG, "Unable to open " + file + " for writing", e); throw e; } }
private void setFileRecordingStatus(boolean enabled) { Log.i(TAG, "Setting recording to " + enabled); if(enabled) { String directory = getPreferenceString(R.string.recording_directory_key); if(directory != null) { if(mFileRecorder == null || !mCurrentDirectory.equals(directory)) { mCurrentDirectory = directory; stopRecording(); mFileRecorder = new FileRecorderSink( new AndroidFileOpener(directory)); getVehicleManager().addSink(mFileRecorder); } } else { Log.d(TAG, "No recording base directory set (" + directory + "), not starting recorder"); } } else { stopRecording(); } }