Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1033473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:14:16+00:00 2026-05-16T14:14:16+00:00

java.lang.IOException, path to file cannot be created. my catch is working by dont know

  • 0

java.lang.IOException, path to file cannot be created. my catch is working by dont know why is isnt being created?

Im not sure why im getting this error, i assumed the setOutputFile() would create the file ..

any help appreciated, as there are a few errors in DDMS

this is my viderecorder class:

    package com.sg86.quickrecord;

    import java.io.File;
    import java.io.IOException;

    import android.media.MediaRecorder;
    import android.os.Environment;

    public class VideoRecorder {

  final MediaRecorder recorder = new MediaRecorder();
     final String path;

     /**
     * create a new video recording stored in SDcard Root
     */
 public VideoRecorder(String path) {
     this.path = organisePath(path);
     }

 private String organisePath(String path) {
  if (!path.startsWith("/")) {
   path = "/" + path;
     }
     if (!path.contains(".")) {
      path += ".3gp";
     }
     return Environment.getExternalStorageDirectory().getAbsolutePath() + path;
     } 
    public void start() throws IOException {
     String state = android.os.Environment.getExternalStorageState();
        if(!state.equals(android.os.Environment.MEDIA_MOUNTED))  {
            throw new IOException("SD Card is not mounted.  It is " + state + ".");
        }

        // make sure the directory we plan to store the recording in exists
        File directory = new File(path).getParentFile();
        if (!directory.exists() && !directory.mkdirs()) {
          throw new IOException("Path to file could not be created.");
        }
        recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
        recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
        recorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
        recorder.setOutputFile(path);
        recorder.prepare();
        recorder.start();
    }
    public void stop() throws IOException {
        recorder.stop();
        recorder.release();
    }
 }

this is my main activity

package com.sg86.quickrecord;

import java.io.File;
import java.io.IOException;
import java.lang.IllegalStateException;

import android.app.Activity;
import android.media.MediaRecorder;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

@SuppressWarnings("unused")
public class QuickRecord extends Activity {

 public static final String WRITE_EXTERNAL_STORAGE = "android.permission.WRITE_EXTERNAL_STORAGE";

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Button recordBtn = (Button) findViewById(R.id.button01);
        Button stopBtn = (Button) findViewById(R.id.button02);
        final VideoRecorder record = new VideoRecorder("/QuickRecord/recording");

        recordBtn.setOnClickListener(new OnClickListener() {   
   public void onClick(View v) {
    // TODO Auto-generated method stub
    try {
     record.start();
    } catch (IOException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
    }
   }
  });

        stopBtn.setOnClickListener(new OnClickListener() {   
   public void onClick(View v) {
    try {
     record.stop();
    } catch (IOException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
    }
   }
  });

    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T14:14:16+00:00Added an answer on May 16, 2026 at 2:14 pm

    Did you add <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> to your AndroidManifest.xml file?

    See Security and Permissions for more details.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

java.lang.IllegalStateException: Could not execute method of the activity . I am new to Android.
import java.lang.System; public class Splitter{ public static void main(String args[]){ String path_separator = Path
import java.lang.Process; import java.io.*; import java.io.InuputStream; import java.io.IOException; public class newsmail{ public static void
import java.lang.Math; public class NewtonIteration { public static void main(String[] args) { System.out.print(rootNofX(2,9)); }
import java.lang.reflect.Array; public class PrimitiveArrayGeneric { static <T> T[] genericArrayNewInstance(Class<T> componentType) { return (T[])
Exception in thread main java.lang.NullPointerException at Library.loadBooks(Library.java:179) at UseLibrary.main(UseLibrary.java:105) This error makes me crazy!
I am calling java.lang.Runtime.exec(...) but this seems to accept the command lines as an
In the following statement: java.lang.Object.wait(Object.java:???)[Native Method] - waiting on <0x6ab0eb48> (a coldfusion.runtime.RWLock) coldfusion.runtime.RWLock.waitForLock(RWLock.java:154) What
I keep getting 21002 'java.lang.NullPointerException' errors from Apple when I try to test my
i got java.lang.NullPointerException by using CrudRepository my project looks like this: strut2 action service

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.