when I run this program(I'm use the mp4prasser Library) I receive an exception:
java.io.IOException: open failed:EACCES (Permission denied)
but in the Manifest I set the permission:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
this is the code(API 17):
public class MainActivity extends AppCompatActivity {
Button mButton;
String Path;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mButton=(Button)findViewById(R.id.button);
mButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
Path= Environment.getExternalStorageDirectory().toString()
+File.separator+"AAAATAG"+File.separator+"abcde.mp4";
startTrim(Path,Environment.getExternalStorageDirectory().toString(),50000,100000);
} catch (IOException e) {
Toast.makeText(MainActivity.this, e.toString(), Toast.LENGTH_SHORT).show();
}
}
});
}
to see the code of the func startTrim()
:
http://pastebin.com/LDjn3Y7f
You should look at the logcat output to verify, but it is most likely because of this line (see in your pastebin) of startTrim()
:
file.getParentFile().mkdirs();
This is attempting to make a destination directory, which the parent of the passed in directory name (Environment.getExternalStorageDirectory()
) plus a filename you have generated. No file separator is added. Since that parent directory is a system controlled directory (and already exists) you won't have permissions to create it. The same call is made later in genVideoUsingMp4Parser()
.
The backtrace in the logcat output should point you right to what call was being made which resulted in the EACCESS
error.