Reputation: 4115
I am using the following code to set the full permission for a file in android. But it is not working. I am not able to find the reason of that. Please help on this.
File mypath=new File(directory, filename+ ".png");
Runtime.getRuntime().exec("chmod 777 " + mypath);
System.out.println("FileExecute " + mypath.canExecute());
System.out.println("FileRead " + mypath.canRead());
System.out.println("FileWrite " + mypath.canWrite());
System.out.println("FileExists " + mypath.exists());
System.out.println("FileisFile " + mypath.isFile());
I am getting every output as 'false'. Is there any other method to set the full permission.
Upvotes: 0
Views: 1564
Reputation: 37566
try:
if (file.exists())
{
file.setExecutable(boolean);
file.setReadable(boolean);
file.setWritable(boolean);
}
Upvotes: 0
Reputation: 8935
If exists()
output is false it means that file dosn't exists so you should first create it by call to mypath.createNewFile()
Upvotes: 2