How can I store an audio file in Internal Storage and Read it and Play it in Android?
<p>I'm making a call recording application and in it I am storing my recorded mp3 audio file in internal storage <code>data/data/mypckagename/myfilename</code> and then I read it and try to play it, but it's not working.</p>

<p>My code for recording:</p>

<pre><code>                date = new SimpleDateFormat("yy-MM-dd").format(new Date(
                        System.currentTimeMillis()));
                String filename = new SimpleDateFormat("yy-MM-dd_HH-mm-ss")
                        .format(new Date(System.currentTimeMillis()));
                String fileName = filename + ".mp3";// Êµ¼ÊÊÇ3gp
                File mydir = getApplicationContext().getDir("mydir",
                        MODE_WORLD_READABLE);

                File recordName = new File(mydir, fileName);

                try {
                    recordName.createNewFile();
                    Log.d("recorder ", "´´½¨ÎÄ¼þ " + recordName.getName());
                } catch (IOException e) {
                    e.printStackTrace();
                }

                recorder.setOutputFile(recordName.getAbsolutePath());
                recorder.prepare(); // Ô¤ÆÚ×¼±¸
                recorder.start(); // ¿ªÊ¼¿ÌÂ¼
                record = true;
                Log.d(TAG, "start record");

                // add a new record to list
                String contactName = getContactName(
                        getApplicationContext(), phoneNumber);
                if (contactName == null || contactName.isEmpty())
                    contactName = phoneNumber;
                date = new SimpleDateFormat("dd-MM-yyyy").format(new Date(
                        System.currentTimeMillis()));
                time = getTime();

                CallInfo c = new CallInfo();
                c.setId(UUID.randomUUID());
                c.setName(contactName);
                c.setPhoneNumber(phoneNumber);
                c.setDate(date + " " + time);
                c.setTime("60s");
                c.setRecordFileName(mydir.getAbsolutePath() + "/"
                        + fileName);
                c.setIsIncoming(isIncoming);

                Log.d(TAG, "µç»°ºÅÂë: " + phoneNumber);

                CallLab.get(getApplicationContext()).addCall(c);
</code></pre>

<p>And for playback:</p>

<pre><code>    File audioFile = new File(c.getRecordFileName());
    System.out.println("path=" + audioFile.toString());
    if (audioFile.exists() &amp;&amp; audioFile.isFile()) {
        // È»ºóÐèÒª»ñÈ¡¸ÃÎÄ¼þµÄUri
        Uri audioUri = Uri.fromFile(audioFile);
        Log.d(TAG, audioUri.toString());
        // È»ºóÖ¸¶¨UriºÍMIME
        final MediaPlayer mediaPlayer=new MediaPlayer();
        FileInputStream fileInputStream = null;
        try {
            fileInputStream = new FileInputStream(audioFile.toString());
        } catch (FileNotFoundException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        try {
            mediaPlayer.setDataSource(audioFile.toString());

            mediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
                public void onPrepared(MediaPlayer player) {
                    mediaPlayer.start();
                  }
                });
        } catch (IllegalArgumentException | IllegalStateException
                | IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
</code></pre>

<p>But the recorded file is not played.</p>