How can I let users access the internal storage directory of my app?

I took a closer look at the result of getFilesDir() vs getExternalFilesDir() and found that getFilesDir() returns /data/data/[packagename]/files while getExternalFilesDir() returns /Android/data/[packagename]/files. I thought the app files I was browsing in /Android/data were the internal storage directories, but now I see that those are actually the external storage directories. If the internal storage directories are … Read more

java set file permissions to 777 while creating a file object [duplicate]

Java SE 7 has java.nio.file.attribute.PosixFileAttributes which gives you fine grained control over read, write, and execute permissions for owner, group, and others. import java.nio.file.*; import java.nio.file.attribute.*; import java.util.Set; public class Test { public static void main(String[] args) throws Exception { Path path = Paths.get(“/tmp/test-file.txt”); if (!Files.exists(path)) Files.createFile(path); Set<PosixFilePermission> perms = Files.readAttributes(path,PosixFileAttributes.class).permissions(); System.out.format(“Permissions before: %s%n”, PosixFilePermissions.toString(perms)); … Read more

How do I set permissions (attributes) on a file in a ZIP file using Python’s zipfile module?

This seems to work (thanks Evan, putting it here so the line is in context): buffer = “path/filename.zip” # zip filename to write (or file-like object) name = “folder/data.txt” # name of file inside zip bytes = “blah blah blah” # contents of file inside zip zip = zipfile.ZipFile(buffer, “w”, zipfile.ZIP_DEFLATED) info = zipfile.ZipInfo(name) info.external_attr … Read more

Automatically apply “git update-index –chmod=+x” to executable files

git 2.9.X/2.10 (Q3 2016) brings chmod to git add itself! See commit 4e55ed3 (31 May 2016) by Edward Thomson (ethomson). Helped-by: Johannes Schindelin (dscho). (Merged by Junio C Hamano — gitster — in commit c8b080a, 06 Jul 2016) add: add –chmod=+x / –chmod=-x options The executable bit will not be detected (and therefore will not … Read more

PowerShell To Set Folder Permissions

Specifying inheritance in the FileSystemAccessRule() constructor fixes this, as demonstrated by the modified code below (notice the two new constuctor parameters inserted between “FullControl” and “Allow”). $Acl = Get-Acl “\\R9N2WRN\Share” $Ar = New-Object System.Security.AccessControl.FileSystemAccessRule(“user”, “FullControl”, “ContainerInherit,ObjectInherit”, “None”, “Allow”) $Acl.SetAccessRule($Ar) Set-Acl “\\R9N2WRN\Share” $Acl According to this topic “when you create a FileSystemAccessRule the way you have, … Read more

mkdir() works while inside internal flash storage, but not SD card?

First, you should note that file.mkdir() and file.mkdirs() returns false if the directory already existed. If you want to know whether the directory exists on return, either use (file.mkdir() || file.isDirectory()) or simply ignore the return value and call file.isDirectory() (see the documentation). That said, your real problem is that you need permission to create … Read more