summaryrefslogtreecommitdiffstats
path: root/fmapp2/src
diff options
context:
space:
mode:
Diffstat (limited to 'fmapp2/src')
-rw-r--r--fmapp2/src/com/caf/fmradio/FMRadioService.java20
1 files changed, 15 insertions, 5 deletions
diff --git a/fmapp2/src/com/caf/fmradio/FMRadioService.java b/fmapp2/src/com/caf/fmradio/FMRadioService.java
index d19af3a..2235e2c 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadioService.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadioService.java
@@ -1126,12 +1126,11 @@ public class FMRadioService extends Service
}
mSampleFile = null;
- File sampleDir = new File(Environment.getExternalStorageDirectory().getAbsolutePath() +"/FMRecording");
- if(!(sampleDir.mkdirs() || sampleDir.isDirectory()))
- return false;
+ File sampleDir = getExternalCacheDir();
+
try {
- mSampleFile = File
- .createTempFile("FMRecording", ".aac", sampleDir);
+ mSampleFile = new File(sampleDir, "FMRecording.aac");
+ mSampleFile.createNewFile();
} catch (IOException e) {
Log.e(LOGTAG, "Not able to access SD Card");
Toast.makeText(this, "Not able to access SD Card", Toast.LENGTH_SHORT).show();
@@ -1225,6 +1224,17 @@ public class FMRadioService extends Service
Log.d(LOGTAG, "storage state is " + state);
if (Environment.MEDIA_MOUNTED.equals(state)) {
+ File finalFile;
+ try {
+ finalFile = File.createTempFile("FMRecording", ".aac",
+ Environment.getExternalStorageDirectory());
+ mSampleFile.renameTo(finalFile);
+ mSampleFile = finalFile;
+ } catch (IOException e) {
+ Log.e(LOGTAG, "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,