diff options
author | Danesh M <daneshm90@gmail.com> | 2014-11-25 12:38:19 -0800 |
---|---|---|
committer | Brint E. Kriebel <bekit@cyngn.com> | 2014-11-25 23:00:46 +0000 |
commit | acde7481a8d87c4d94ee3cfc937ef7f1ad24253e (patch) | |
tree | 2c41b4d193b6509500734bbe18a99c113f6268a4 | |
parent | 00c2c96bdecc2ed354cbada93df7f8ce5182af1b (diff) | |
download | android_hardware_qcom_fm-acde7481a8d87c4d94ee3cfc937ef7f1ad24253e.tar.gz android_hardware_qcom_fm-acde7481a8d87c4d94ee3cfc937ef7f1ad24253e.tar.bz2 android_hardware_qcom_fm-acde7481a8d87c4d94ee3cfc937ef7f1ad24253e.zip |
FMRecorder : Save to a private temporary file while recording
While recording save to a temporary private file and once finished,
move to external storage
Change-Id: If82a84beeffe2ea8e5ba4bf7e93e4f3d6203e10f
(cherry picked from commit 3d6236300fdc02fefc2032c482c8a0fcf71649b1)
-rw-r--r-- | FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java b/FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java index bf99dd8..febbbde 100644 --- a/FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java +++ b/FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java @@ -259,10 +259,11 @@ public class FMRecordingService extends Service { } mSampleFile = null; - File sampleDir = Environment.getExternalStorageDirectory(); + File sampleDir = getExternalCacheDir(); try { - mSampleFile = File.createTempFile("FMRecording", ".3gpp", sampleDir); + mSampleFile = new File(sampleDir, "FMRecording.3gpp"); + mSampleFile.createNewFile(); } catch (IOException e) { Log.e(TAG, "Not able to access SD Card"); Toast.makeText(this, "Not able to access SD Card", Toast.LENGTH_SHORT).show(); @@ -370,6 +371,18 @@ public class FMRecordingService extends Service { Log.d(TAG, "storage state is " + state); if (Environment.MEDIA_MOUNTED.equals(state)) { + File finalFile; + try { + finalFile = File.createTempFile("FMRecording", ".3gpp", + Environment.getExternalStorageDirectory()); + mSampleFile.renameTo(finalFile); + mSampleFile = finalFile; + } catch (IOException e) { + Log.e(TAG, "Not able to access SD Card"); + Toast.makeText(this, "Not able to access SD Card", Toast.LENGTH_SHORT).show(); + e.printStackTrace(); + } + try { this.addToMediaDB(mSampleFile); Toast.makeText(this,getString(R.string.save_record_file, |