Friday, February 28, 2014

In the program folder does not have permission to write files prompt


I want to write a program folder configuration file, the same code, before running no problem, how can today afford to create the file, suggesting that there is no authority to ask the heroes who know how it is, thank you, the following code :
 
FloatWindowService.AppPath = getApplicationContext (). GetFilesDir ()
. GetAbsolutePath ();
flipper_getdata = (ViewFlipper) findViewById (R.id.flipper_getdata);
bar = (ProgressBar) findViewById (R.id.progressBar1);
/ / Create a settings file
here
/ / Check directory exists
File file = new File (FloatWindowService.AppPath);
FloatWindowService.AppPath = FloatWindowService.AppPath
+ "/ Set_data.tyzj";
/ / Set the file to see if there is

file = new File (FloatWindowService.AppPath);
if (! file.exists ()) / / if it does not exist create
{/ / Create a file

try
{File.createNewFile () ;/ / phrase wrong, e.getMessage () is "Permission denied"
Log.v ("message", "file has been created successfully.") ;/ / Not execute the sentence
FloatWindowService.SetFileWrite = openFileOutput (
"Set_data.tyzj", MODE_PRIVATE);
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Yellow error message as follows:

10-26 10:21:38.363: W / System.err (5410): java.io.IOException: Permission denied
10-26 10:21:38.364: W / System.err (5410): at java.io.File.createNewFileImpl (Native Method)
10-26 10:21:38.364: W / System.err (5410): at java.io.File.createNewFile (File.java: 1288)
10-26 10:21:38.365: W / System.err (5410): at com.TianYe.ZhiNengJiaJu.MainActivity.onCreate (MainActivity.java: 60)
10-26 10:21:38.365: W / System.err (5410): at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java: 1082)
10-26 10:21:38.365: W / System.err (5410): at android.app.ActivityThread.performLaunchActivity (ActivityThread.java: 1692)
10-26 10:21:38.365: W / System.err (5410): at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java: 1747)
10-26 10:21:38.366: W / System.err (5410): at android.app.ActivityThread.access $ 1500 (ActivityThread.java: 155)
10-26 10:21:38.366: W / System.err (5410): at android.app.ActivityThread $ H.handleMessage (ActivityThread.java: 993)
10-26 10:21:38.366: W / System.err (5410): at android.os.Handler.dispatchMessage (Handler.java: 130)
10-26 10:21:38.366: W / System.err (5410): at android.os.Looper.loop (SourceFile: 351)
10-26 10:21:38.366: W / System.err (5410): at android.app.ActivityThread.main (ActivityThread.java: 3814)
10-26 10:21:38.367: W / System.err (5410): at java.lang.reflect.Method.invokeNative (Native Method)
10-26 10:21:38.367: W / System.err (5410): at java.lang.reflect.Method.invoke (Method.java: 538)
10-26 10:21:38.367: W / System.err (5410): at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java: 901)
10-26 10:21:38.368: W / System.err (5410): at com.android.internal.os.ZygoteInit.main (ZygoteInit.java: 659)
10-26 10:21:38.368: W / System.err (5410): at dalvik.system.NativeStart.main (Native Method)

Reply:
I have always been connected to the real machine, the virtual machine tried it, can create a file, I do not know where my phone has been met, before the normal procedure, in order to test the application in the local management to clear the data, and then unloaded, After it is not alright
Reply:
Manifest in plus permission to try
  

Reply:
Look no authority added


Then open the android emulator to check in the creation of this simulator sd card has not been created
Reply:
Thanks to the above two friends, but I did not write sd card, but the private folder to write the program, the program does have to write another sd card, so this permission is yes. There is a virtual machine is no problem, but the problem is real machine, fax machine and no problem before, only appeared recently, I feel very strange.

No comments:

Post a Comment