在Android文件权限权限、文件、Android

由网友(蓝颜,蓝着蓝着就绿了)分享简介:首先,嗨大家,我在这里只是提出一些也许很简单,我正与文件,的FileOutputStream 和的FileInputStream ,但我只是想获取/设置一些道具的文件,我的意思是,主人文件,权限读/写等。环顾四周,我发现的类的FileDescriptor 和的FilePermission ,但我没有一个想法,而我可以使...

首先,嗨大家,我在这里只是提出一些也许很简单,我正与文件,的FileOutputStream 和的FileInputStream ,但我只是想获取/设置一些道具的文件,我的意思是,主人文件,权限读/写等。

环顾四周,我发现的类的FileDescriptor 和的FilePermission ,但我没有一个想法,而我可以使用它们,所以我问了一些关于这个帮助;其实我使用的方法通过setReadOnly()从类的文件但现在我要找的。

感谢您对大家的帮助。

解决方案

有几个问题在这里:

应用程序,默认情况下,无限制地访问自己的文件(读/写/删除/'执行'......不管执行装置),但到任何其他应用程序文件的访问权限。 机器人使其难以与其他应用程序和它们的数据,除非通过意图交互。意图将不会对权限的工作,因为你是依赖于应用程序接收的意图做/提供你想要的东西;他们可能没有被设计成告诉任何人他们的文件的权限。大约有它的方式,但只有当应用程序desgned在同一个JVM运行(即应用程序,你已经设计在同一个JVM运行起来) 理解android中的内部存储与外部存储 续

您的应用程序可以获取和设置权限的它自己的文件的,但不能做到这一点对别人的人。据我所知,所有的SDK暴露的没有明确的概念,所以你无法找到一个文件的所有者。

的Andr​​oid是基于Linux内核,但它不是Linux。这对于在移动设备上运行了大量优化。如果你有一台机器,其中一个应用程序只能在自己的沙盒玩,你可以切出像权限和所有权,并得到一个更小,更快的操作系统。你的文件有唯一的权限是一个人的,你的地方(和执行),在他们身上。其他应用程序的文件不存在

First of all, Hi to everyone, I'm here just to ask something maybe very simple, I'm working with Files, FileOutputStream and FileInputStream, But I just want to get/set a few props from the file, I mean, the owner the file, the permissions read/write, etc.

Looking around I found the classes FileDescriptor and FilePermission but I don't have an idea of which I can use them, so I asking for some help about this; Actually I'm using the method setReadOnly() from the class File but that's now what I'm looking for.

Thank you all of you for your help.

解决方案

There are a couple of issues here:

An application, by default, has unrestricted access to its own files (read/write/delete/'execute'...whatever execute means) but no access to any other application's files. Android make it difficult to interact with other applications and their data except through Intents. Intents won't work for permissions because you're dependent on the application receiving the Intent to do/provide what you want; they probably weren't designed to tell anybody their files' permissions. There are ways around it, but only when the applications are desgned to operate in the same JVM (i.e. applications you have designed to operate in the same JVM together)

Your application can get and set permissions for its own files but cannot do that for anyone elses. To my knowledge there is no explicit concept of ownership exposed in the SDK, so you cannot find the owner of a file.

Android is based on the Linux kernel, but it's not Linux. It's been heavily optimized for running on mobile devices. If you have a machine where an application can only play in its own sandbox you can cut out things like permissions and ownership and get a smaller, faster operating system. The only permissions your files have are the one's you place (and enforce) on them. Other applications' files do not exist.

阅读全文

相关推荐

最新文章