Not used openfileout ...
What other way?
Create a file directly reported to the ordinary open failed: EACCES (Permission denied) exception.
Trouble help!
Reply:
Permission denied, will appear for ways
Reply:
Back upstairs, authorities have added
Reply:
Although the authority added, but you should pay attention to the position of authority: http://www .apkbus.com/android-15617-1-1.html
Reply:
FileOutputStream os = ctx.openFileOutput (file.getName (), Context.MODE_WORLD_WRITEABLE);
Reply:
if (! file.exists ()) {
file.createNewFile ();
}
FileOutputStream os = ctx.openFileOutput (file.getName (),
Context.MODE_WORLD_WRITEABLE);
byte [] bytes = new byte [512];
int i = -1;
while ((i = is.read (bytes))> 0) {
os.write (bytes);
}
os.close ();
is.close ();
String permission = "666";
try {
String command = "chmod" + permission + "" + apkPath
+ "/" + DestapkName;
Runtime runtime = Runtime.getRuntime ();
runtime.exec (command);
} Catch (IOException e) {
e.printStackTrace ();
}
Reply:
Learn.

Reply:
I am optimistic about the trouble upstairs right questions before you speak.
I mean to write the file to / data / data / packagename / files go inside
In addition openFileOutput What other methods.
If the direct simple createnewfile () and so on, will be reported open failed: EACCE wrong ..
Reply:
If packagename, not your current call createnewfile application package name, there is no authority
Reply:
It is the key to the package name of my own program. Dude, give an explanation ah. Thank you
Reply:
I looked at, / data / data / packagename / files permissions in the files is 700, system system, proved only have permission to create the file system permissions on the inside, you want to create the file if it is in the inside, then you need to manually modify permissions files file.
Reply:
String apkPath = "/ data / data /" + getPackageName () + "/ files";
Doubt your wrong path, not a privilege
problemPlease refer
http://ccsosnfs.iteye.com/blog/1390405
Reply:
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import android.app.Activity;
import android.os.Bundle;
public class FileTestActivity extends Activity {
/ ** Called when the activity is first created. * /
@ Override
public void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setContentView (R.layout.main);
/ / Create the input and output stream object
FileOutputStream outfile = null;
FileInputStream infile = null;
try {
/ / Create two objects openFileOutput openFile (the) two parameters
/ / The first one is the file name, and the second is the attribute, 0 represents only allows applications to manipulate the file
outfile = this.openFileOutput ("test.txt", 0);
infile = this.openFileInput ("test.txt");
} Catch (FileNotFoundException e1) {
/ / TODO Auto-generated catch block
e1.printStackTrace ();
}
DataOutputStream dout = null;
try {
/ / Write file
dout = new DataOutputStream (outfile);
dout.writeUTF ("testtesttesttesttesttest");
dout.close ();
} Catch (IOException e) {
/ / TODO Auto-generated catch block
e.printStackTrace ();
}
DataInputStream din = null;
/ / Read file
din = new DataInputStream (infile);
String result = null;
try {
result = din.readLine ();
} Catch (IOException e) {
/ / TODO Auto-generated catch block
e.printStackTrace ();
}
System.out.println (result);
}
}
With openFileOutput not need to add permissions ah ...
Reply:
12th floor can Yeah,
To the point of it,
Reply:
Create a file, use an absolute path, for example:
File outfilepath = new File (Environment.getExternalStorageDirectory (), "/ myfiles");
new File (outfilepath.getAbsolutePath (), outfileName);
Reply:
Reply:
Hello, my question is in the / data / data / packagename / files created inside what files are always being given. Not to say that how to create a file.
Reply:
Solved.
After less than csdn on to ask questions.
Reply:
Themselves, they should tell how to solve, or how to leave a good experience for the future of the people
To share Ha
Reply:
The main problem some people see the answer inexplicable feeling depressed! Many times.
Get as you said. But it is still in the permissions problem / data / data file operations.
Additional parameters Context.MODE_WORLD_WRITEABLE + Context.MODE_WORLD_READABLE +
Context.MODE_APPEND.
Reply:
Landlord Hello, I would like to ask, if the path to modify the value of the following documents which are not also add this permission ah? ? ? I did not add any permissions on the simulator, but can be modified. . . But did not modify packaged into apk later to the real machine later. . . Read the entire post. . . They seem to say no permission to use fileoutput. . . I used this but still no changes. . .
Reply:
There is such a possibility. That you did not mount the sd card. With the real test will easily so. Wiper try again
Reply:
The main problem some people see the answer inexplicable feeling depressed! Many times.
Get as you said. But it is still in the permissions problem / data / data file operations.
Additional parameters Context.MODE_WORLD_WRITEABLE + Context.MODE_WORLD_READABLE +
Context.MODE_APPEND.
No comments:
Post a Comment