我在这部分代码中发生了非法参数异常:
boolean mExternalStorageAvailable = false;
boolean mExternalStorageWriteable = false;
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state)) {
String root = Environment.getExternalStorageDirectory().toString();
full_path = root+getResources().getString(R.string.app_name) ;
File dir_path = getApplicationContext().getDir(full_path, MODE_PRIVATE);
这是错误日志:
03-08 12:26:23.717: E/AndroidRuntime(9234): FATAL EXCEPTION: main
03-08 12:26:23.717: E/AndroidRuntime(9234): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.streamfilesys/com.example.streamfilesys.MainActivity}: java.lang.IllegalArgumentException: File app_/storage/emulated/0/StreamFileSys contains a path separator
03-08 12:26:23.717: E/AndroidRuntime(9234): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
03-08 12:26:23.717: E/AndroidRuntime(9234): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
03-08 12:26:23.717: E/AndroidRuntime(9234): at android.app.ActivityThread.access$600(ActivityThread.java:141)
03-08 12:26:23.717: E/AndroidRuntime(9234): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
03-08 12:26:23.717: E/AndroidRuntime(9234): at android.os.Handler.dispatchMessage(Handler.java:99)
03-08 12:26:23.717: E/AndroidRuntime(9234): at android.os.Looper.loop(Looper.java:137)
03-08 12:26:23.717: E/AndroidRuntime(9234): at android.app.ActivityThread.main(ActivityThread.java:5041)
03-08 12:26:23.717: E/AndroidRuntime(9234): at java.lang.reflect.Method.invokeNative(Native Method)
03-08 12:26:23.717: E/AndroidRuntime(9234): at java.lang.reflect.Method.invoke(Method.java:511)
03-08 12:26:23.717: E/AndroidRuntime(9234): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
03-08 12:26:23.717: E/AndroidRuntime(9234): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
03-08 12:26:23.717: E/AndroidRuntime(9234): at dalvik.system.NativeStart.main(Native Method)
03-08 12:26:23.717: E/AndroidRuntime(9234): Caused by: java.lang.IllegalArgumentException: File app_/storage/emulated/0/StreamFileSys contains a path separator
03-08 12:26:23.717: E/AndroidRuntime(9234): at android.app.ContextImpl.makeFilename(ContextImpl.java:1966)
03-08 12:26:23.717: E/AndroidRuntime(9234): at android.app.ContextImpl.getDir(ContextImpl.java:1816)
03-08 12:26:23.717: E/AndroidRuntime(9234): at android.content.ContextWrapper.getDir(ContextWrapper.java:218)
03-08 12:26:23.717: E/AndroidRuntime(9234): at com.example.streamfilesys.MainActivity.onCreate(MainActivity.java:39)
03-08 12:26:23.717: E/AndroidRuntime(9234): at android.app.Activity.performCreate(Activity.java:5104)
03-08 12:26:23.717: E/AndroidRuntime(9234): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
03-08 12:26:23.717: E/AndroidRuntime(9234): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
03-08 12:26:23.717: E/AndroidRuntime(9234): ... 11 more
mainActivity 线 39 是
File dir_path = getApplicationContext().getDir(full_path, MODE_PRIVATE);
我该如何解决?