Android examples for android.media:Audio
get Audio Filename in yyyyMMdd_HHmmss format
import java.io.File; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import android.content.Context; import android.util.Log; public class Main{ public static File getAudioFilename(Context context) throws IOException { String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US).format(new Date()); String audioFileName = "AUD_" + timeStamp + ".m4a"; File storageDir = new File(context.getExternalFilesDir(null), "audio"); if (!storageDir.exists()) { boolean makeDir = storageDir.mkdirs(); if (!makeDir) { throw new IOException( "Unable to create parent dirs for image file."); } else { Log.d("","Created parent dir structure for file."); }//from w ww . jav a 2 s . com } File audioFile = new File(storageDir, audioFileName); if (audioFile.createNewFile()) { Log.d("","Created new audio file : " + audioFile.getAbsolutePath()); } else { Log.d("","New file not created; already exists?"); } return audioFile; } }