How to create sdcard in emulater to save recorded file??


  1. ambblr108

    ambblr108 New Member

    Hi all,
    i am beginner in android development.i am trying to recording on button click.

    mycode is following::
    HTML Code:
    HTML:
    1. private void StartAudioRecording() {
    2.         File sampleDir=Environment.getExternalStorageDirectory();
    3.         try {
    4.             audioFile=File.createTempFile("sound","3gp",sampleDir);
    5.         } catch (IOException e) {
    6.             // TODO Auto-generated catch block
    7.             e.printStackTrace();
    8.         }
    9.        
    10.         recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
    11.         recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
    12.         recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
    13.         recorder.setOutputFile(audioFile.getAbsolutePath());
    14.         try {
    15.             recorder.prepare();
    16.         } catch (IllegalStateException e) {
    17.             // TODO Auto-generated catch block
    18.             e.printStackTrace();
    19.         } catch (IOException e) {
    20.             // TODO Auto-generated catch block
    21.             e.printStackTrace();
    22.         }
    23.         recorder.start();
    24.     }
    when i was running application in debug mode application getting crash.pls tell me what is wrong in this code.....
    i am not getting sdcard path .

    pls help me how to solve my issue.

    thanks in advance
    Ambrish Singh

    Advertisement
  2. jonbonazza

    jonbonazza Well-Known Member

    Can you please post the log cat output?
  3. ambblr108

    ambblr108 New Member

    This is my LOG CAT::
    10-02 20:13:01.220: W/ActivityThread(274): Application com.example.acumobile is waiting for the debugger on port 8100...
    10-02 20:13:01.240: I/System.out(274): Sending WAIT chunk
    10-02 20:13:01.320: I/dalvikvm(274): Debugger is active
    10-02 20:13:01.450: I/System.out(274): Debugger has connected
    10-02 20:13:01.450: I/System.out(274): waiting for debugger to settle...
    10-02 20:13:01.650: I/System.out(274): waiting for debugger to settle...
    10-02 20:13:01.850: I/System.out(274): waiting for debugger to settle...
    10-02 20:13:02.049: I/System.out(274): waiting for debugger to settle...
    10-02 20:13:02.250: I/System.out(274): waiting for debugger to settle...
    10-02 20:13:02.452: I/System.out(274): waiting for debugger to settle...
    10-02 20:13:02.659: I/System.out(274): waiting for debugger to settle...
    10-02 20:13:02.859: I/System.out(274): waiting for debugger to settle...
    10-02 20:13:03.060: I/System.out(274): waiting for debugger to settle...
    10-02 20:13:03.260: I/System.out(274): waiting for debugger to settle...
    10-02 20:13:03.460: I/System.out(274): waiting for debugger to settle...
    10-02 20:13:03.669: I/System.out(274): debugger has settled (1443)
    10-02 20:15:42.639: D/AndroidRuntime(274): Shutting down VM
    10-02 20:15:42.639: W/dalvikvm(274): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
    10-02 20:15:42.700: E/AndroidRuntime(274): FATAL EXCEPTION: main
    10-02 20:15:42.700: E/AndroidRuntime(274): java.lang.NullPointerException
    10-02 20:15:42.700: E/AndroidRuntime(274): at com.example.acumobile.AcuAudioRecording.StartAudioRecording(AcuAudioRecording.java:54)
    10-02 20:15:42.700: E/AndroidRuntime(274): at com.example.acumobile.AcuAudioRecording.StartRecording(AcuAudioRecording.java:27)
    10-02 20:15:42.700: E/AndroidRuntime(274): at com.example.acumobile.Dictatte$2.onClick(Dictatte.java:34)
    10-02 20:15:42.700: E/AndroidRuntime(274): at android.view.View.performClick(View.java:2408)
    10-02 20:15:42.700: E/AndroidRuntime(274): at android.view.View$PerformClick.run(View.java:8816)
    10-02 20:15:42.700: E/AndroidRuntime(274): at android.os.Handler.handleCallback(Handler.java:587)
    10-02 20:15:42.700: E/AndroidRuntime(274): at android.os.Handler.dispatchMessage(Handler.java:92)
    10-02 20:15:42.700: E/AndroidRuntime(274): at android.os.Looper.loop(Looper.java:123)
    10-02 20:15:42.700: E/AndroidRuntime(274): at android.app.ActivityThread.main(ActivityThread.java:4627)
    10-02 20:15:42.700: E/AndroidRuntime(274): at java.lang.reflect.Method.invokeNative(Native Method)
    10-02 20:15:42.700: E/AndroidRuntime(274): at java.lang.reflect.Method.invoke(Method.java:521)
    10-02 20:15:42.700: E/AndroidRuntime(274): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    10-02 20:15:42.700: E/AndroidRuntime(274): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    10-02 20:15:42.700: E/AndroidRuntime(274): at dalvik.system.NativeStart.main(Native Method)
    10-02 20:16:12.050: W/ActivityThread(304): Application com.example.acumobile is waiting for the debugger on port 8100...
    10-02 20:16:12.081: I/System.out(304): Sending WAIT chunk
    10-02 20:16:12.081: I/dalvikvm(304): Debugger is active
    10-02 20:16:12.131: I/System.out(304): Debugger has connected
    10-02 20:16:12.131: I/System.out(304): waiting for debugger to settle...
    10-02 20:16:12.330: I/System.out(304): waiting for debugger to settle...
    10-02 20:16:12.581: I/System.out(304): waiting for debugger to settle...
    10-02 20:16:12.781: I/System.out(304): waiting for debugger to settle...
    10-02 20:16:12.980: I/System.out(304): waiting for debugger to settle...
    10-02 20:16:13.181: I/System.out(304): waiting for debugger to settle...
    10-02 20:16:13.380: I/System.out(304): waiting for debugger to settle...
    10-02 20:16:13.589: I/System.out(304): debugger has settled (1491)
    10-02 20:17:15.080: D/AndroidRuntime(304): Shutting down VM
    10-02 20:17:15.080: W/dalvikvm(304): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
    10-02 20:17:15.161: E/AndroidRuntime(304): FATAL EXCEPTION: main
    10-02 20:17:15.161: E/AndroidRuntime(304): java.lang.NullPointerException
    10-02 20:17:15.161: E/AndroidRuntime(304): at com.example.acumobile.AcuAudioRecording.StartAudioRecording(AcuAudioRecording.java:54)
    10-02 20:17:15.161: E/AndroidRuntime(304): at com.example.acumobile.AcuAudioRecording.StartRecording(AcuAudioRecording.java:27)
    10-02 20:17:15.161: E/AndroidRuntime(304): at com.example.acumobile.Dictatte$2.onClick(Dictatte.java:34)
    10-02 20:17:15.161: E/AndroidRuntime(304): at android.view.View.performClick(View.java:2408)
    10-02 20:17:15.161: E/AndroidRuntime(304): at android.view.View$PerformClick.run(View.java:8816)
    10-02 20:17:15.161: E/AndroidRuntime(304): at android.os.Handler.handleCallback(Handler.java:587)
    10-02 20:17:15.161: E/AndroidRuntime(304): at android.os.Handler.dispatchMessage(Handler.java:92)
    10-02 20:17:15.161: E/AndroidRuntime(304): at android.os.Looper.loop(Looper.java:123)
    10-02 20:17:15.161: E/AndroidRuntime(304): at android.app.ActivityThread.main(ActivityThread.java:4627)
    10-02 20:17:15.161: E/AndroidRuntime(304): at java.lang.reflect.Method.invokeNative(Native Method)
    10-02 20:17:15.161: E/AndroidRuntime(304): at java.lang.reflect.Method.invoke(Method.java:521)
    10-02 20:17:15.161: E/AndroidRuntime(304): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    10-02 20:17:15.161: E/AndroidRuntime(304): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    10-02 20:17:15.161: E/AndroidRuntime(304): at dalvik.system.NativeStart.main(Native Method)
    10-02 20:17:47.550: W/ActivityThread(329): Application com.example.acumobile is waiting for the debugger on port 8100...
    10-02 20:17:47.601: I/System.out(329): Sending WAIT chunk
    10-02 20:17:47.601: I/dalvikvm(329): Debugger is active
    10-02 20:17:47.610: I/System.out(329): Debugger has connected
    10-02 20:17:47.620: I/System.out(329): waiting for debugger to settle...
    10-02 20:17:47.931: I/System.out(329): waiting for debugger to settle...
    10-02 20:17:48.130: I/System.out(329): waiting for debugger to settle...
    10-02 20:17:48.330: I/System.out(329): waiting for debugger to settle...
    10-02 20:17:48.530: I/System.out(329): waiting for debugger to settle...
    10-02 20:17:48.789: I/System.out(329): waiting for debugger to settle...
    10-02 20:17:48.990: I/System.out(329): debugger has settled (1364)
    10-02 20:21:08.590: W/ActivityThread(351): Application com.example.acumobile is waiting for the debugger on port 8100...
    10-02 20:21:08.600: I/System.out(351): Sending WAIT chunk
    10-02 20:21:08.609: I/dalvikvm(351): Debugger is active
    10-02 20:21:08.809: I/System.out(351): Debugger has connected
    10-02 20:21:08.809: I/System.out(351): waiting for debugger to settle...
    10-02 20:21:09.009: I/System.out(351): waiting for debugger to settle...
    10-02 20:21:09.220: I/System.out(351): waiting for debugger to settle...
    10-02 20:21:09.419: I/System.out(351): waiting for debugger to settle...
    10-02 20:21:09.619: I/System.out(351): waiting for debugger to settle...
    10-02 20:21:09.829: I/System.out(351): waiting for debugger to settle...
    10-02 20:21:10.029: I/System.out(351): debugger has settled (1405)
    10-02 20:23:14.284: D/AndroidRuntime(351): Shutting down VM
    10-02 20:23:14.284: W/dalvikvm(351): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
    10-02 20:23:34.239: E/AndroidRuntime(351): FATAL EXCEPTION: main
    10-02 20:23:34.239: E/AndroidRuntime(351): java.lang.NullPointerException
    10-02 20:23:34.239: E/AndroidRuntime(351): at com.example.acumobile.AcuAudioRecording.StartAudioRecording(AcuAudioRecording.java:54)
    10-02 20:23:34.239: E/AndroidRuntime(351): at com.example.acumobile.AcuAudioRecording.StartRecording(AcuAudioRecording.java:27)
    10-02 20:23:34.239: E/AndroidRuntime(351): at com.example.acumobile.Dictatte$2.onClick(Dictatte.java:34)
    10-02 20:23:34.239: E/AndroidRuntime(351): at android.view.View.performClick(View.java:2408)
    10-02 20:23:34.239: E/AndroidRuntime(351): at android.view.View$PerformClick.run(View.java:8816)
    10-02 20:23:34.239: E/AndroidRuntime(351): at android.os.Handler.handleCallback(Handler.java:587)
    10-02 20:23:34.239: E/AndroidRuntime(351): at android.os.Handler.dispatchMessage(Handler.java:92)
    10-02 20:23:34.239: E/AndroidRuntime(351): at android.os.Looper.loop(Looper.java:123)
    10-02 20:23:34.239: E/AndroidRuntime(351): at android.app.ActivityThread.main(ActivityThread.java:4627)
    10-02 20:23:34.239: E/AndroidRuntime(351): at java.lang.reflect.Method.invokeNative(Native Method)
    10-02 20:23:34.239: E/AndroidRuntime(351): at java.lang.reflect.Method.invoke(Method.java:521)
    10-02 20:23:34.239: E/AndroidRuntime(351): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    10-02 20:23:34.239: E/AndroidRuntime(351): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    10-02 20:23:34.239: E/AndroidRuntime(351): at dalvik.system.NativeStart.main(Native Method)
    10-02 20:24:11.749: W/ActivityThread(375): Application com.example.acumobile is waiting for the debugger on port 8100...
    10-02 20:24:11.779: I/System.out(375): Sending WAIT chunk
    10-02 20:24:11.789: I/dalvikvm(375): Debugger is active
    10-02 20:24:11.979: I/System.out(375): Debugger has connected
    10-02 20:24:11.979: I/System.out(375): waiting for debugger to settle...
    10-02 20:24:12.180: I/System.out(375): waiting for debugger to settle...
    10-02 20:24:12.390: I/System.out(375): waiting for debugger to settle...
    10-02 20:24:12.590: I/System.out(375): waiting for debugger to settle...
    10-02 20:24:12.789: I/System.out(375): waiting for debugger to settle...
    10-02 20:24:12.989: I/System.out(375): waiting for debugger to settle...
    10-02 20:24:13.189: I/System.out(375): debugger has settled (1395)
    10-02 20:26:37.609: D/AndroidRuntime(375): Shutting down VM
    10-02 20:26:37.609: W/dalvikvm(375): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
    10-02 20:26:37.689: E/AndroidRuntime(375): FATAL EXCEPTION: main
    10-02 20:26:37.689: E/AndroidRuntime(375): java.lang.NullPointerException
    10-02 20:26:37.689: E/AndroidRuntime(375): at com.example.acumobile.AcuAudioRecording.StartAudioRecording(AcuAudioRecording.java:54)
    10-02 20:26:37.689: E/AndroidRuntime(375): at com.example.acumobile.AcuAudioRecording.StartRecording(AcuAudioRecording.java:27)
    10-02 20:26:37.689: E/AndroidRuntime(375): at com.example.acumobile.Dictatte$2.onClick(Dictatte.java:34)
    10-02 20:26:37.689: E/AndroidRuntime(375): at android.view.View.performClick(View.java:2408)
    10-02 20:26:37.689: E/AndroidRuntime(375): at android.view.View$PerformClick.run(View.java:8816)
    10-02 20:26:37.689: E/AndroidRuntime(375): at android.os.Handler.handleCallback(Handler.java:587)
    10-02 20:26:37.689: E/AndroidRuntime(375): at android.os.Handler.dispatchMessage(Handler.java:92)
    10-02 20:26:37.689: E/AndroidRuntime(375): at android.os.Looper.loop(Looper.java:123)
    10-02 20:26:37.689: E/AndroidRuntime(375): at android.app.ActivityThread.main(ActivityThread.java:4627)
    10-02 20:26:37.689: E/AndroidRuntime(375): at java.lang.reflect.Method.invokeNative(Native Method)
    10-02 20:26:37.689: E/AndroidRuntime(375): at java.lang.reflect.Method.invoke(Method.java:521)
    10-02 20:26:37.689: E/AndroidRuntime(375): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    10-02 20:26:37.689: E/AndroidRuntime(375): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    10-02 20:26:37.689: E/AndroidRuntime(375): at dalvik.system.NativeStart.main(Native Method)
    10-02 20:27:06.679: W/ActivityThread(399): Application com.example.acumobile is waiting for the debugger on port 8100...
    10-02 20:27:06.729: I/System.out(399): Sending WAIT chunk
    10-02 20:27:06.729: I/dalvikvm(399): Debugger is active
    10-02 20:27:06.933: I/System.out(399): Debugger has connected
    10-02 20:27:06.933: I/System.out(399): waiting for debugger to settle...
    10-02 20:27:07.140: I/System.out(399): waiting for debugger to settle...
    10-02 20:27:07.339: I/System.out(399): waiting for debugger to settle...
    10-02 20:27:07.539: I/System.out(399): waiting for debugger to settle...
    10-02 20:27:07.739: I/System.out(399): waiting for debugger to settle...
    10-02 20:27:07.939: I/System.out(399): waiting for debugger to settle...
    10-02 20:27:08.149: I/System.out(399): debugger has settled (1407)


    i am getting exception::
    Source file not found when i am debugging the application......
    pls help me
  4. jonbonazza

    jonbonazza Well-Known Member

    What is line 54 in your AcuAudioRecording class (AcuAudioRecording.java file)?
Loading...

Share This Page