Android 如何从data/data/my_包读取数据

Android 如何从data/data/my_包读取数据,android,Android,我已将视频文件下载到data/data/my_package/video.mp4中,现在我想知道如何播放此视频。我正在使用Eclipse。提前谢谢 DownloadFromUrl("PATH"+videoname.mp4) { public void DownloadFromUrl(String fileName) { try { URL url = new URL("http://www.bestbusinessplaces

我已将视频文件下载到data/data/my_package/video.mp4中,现在我想知道如何播放此视频。我正在使用Eclipse。提前谢谢

 DownloadFromUrl("PATH"+videoname.mp4)
{

public void DownloadFromUrl(String fileName) {

            try {
                    URL url = new URL("http://www.bestbusinessplaces.com/animation/admin/Animation/132404046113240392391323340839intelligent_cartridge.mp4-muxed_0.mp4-muxed.mp4"); //you can write here any link

                   File file = new File(fileName);

                   long startTime = System.currentTimeMillis();

                    tv.setText("Starting download......from " + url);

                    URLConnection ucon = url.openConnection();

                    InputStream is = ucon.getInputStream();

                    BufferedInputStream bis = new BufferedInputStream(is);

                    /*

                     * Read bytes to the Buffer until there is nothing more to read(-1).

                     */

                    ByteArrayBuffer baf = new ByteArrayBuffer(50);

                    int current = 0;

                    while ((current = bis.read()) != -1) {

                            baf.append((byte) current);

                    }


                   FileOutputStream fos = new FileOutputStream(file);

                   fos.write(baf.toByteArray());

                   fileOutput.close();
                   fos.close();

                    tv.setText("Download Completed in" + ((System.currentTimeMillis() - startTime) / 1000) + " sec");

            } catch (IOException e) {

                 tv.setText("Error: " + e);

            }

    }

当您将视频存储在内部存储器中时,请确保其具有MODE_WORLD_可读权限,以便媒体播放器可以访问它

所以,存储视频,比如

OutputStream myOutput = openFileOutput("Video_filename.mp4", Context.MODE_WORLD_READABLE);
然后使用路径设置视频源

FileInputStream fileInputStream = new FileInputStream("/data/data/com.mypackage/myfile");
mediaPlayer.setDataSource(fileInputStream.getFD());
编辑:


这个视频文件的权限是什么?-rw----这是这个视频文件的权限这是不工作的OutputStream myOutput=openFileOutputVideo\u filename.mp4,Context.MODE\u WORLD\u READABLE;可能是我做错了,所以请给我一个示例代码,如果可能的话请我添加了代码请检查并告诉我如何播放data/data/my_软件包中的视频
 URL url;        
 URLConnection ucon = null;

 url = new URL("http://www.bestbusinessplaces.com/animation/admin/Animation/132404046113240392391323340839intelligent_cartridge.mp4-muxed_0.mp4-muxed.mp4");
 ucon = url.openConnection();
 InputStream is = null;
 is = ucon.getInputStream();
 OutputStream myOutput = openFileOutput("test_video.mp4", Context.MODE_WORLD_READABLE);

 try {
    byte[] buffer = new byte[8192];
    int length;
    while ( (length = is.read(buffer)) > 0 ) {
           myOutput.write(buffer);
      }

   //Close the streams
   myOutput.flush();
   myOutput.close();
   is.close();

  } catch (IOException e) {

      }