PFA the png, in this please note the permissions for the images inside app_themes directory. I am creating and adding files to this directory(app_themes) and during the process I do not specify any permissions at all.
Now I can see, for some png's the permission is rwxrwxrwx and for some others, it is just rw.
Though I do not specify any permission at all, why this difference in permission occurs?
I have no issues while I access a file with rwxrwxrwx from a different application, but cannot access those files which has only rw permission from a second application.
Please let me know how to resolve this by having the same permission - rwxrwxrwx for all the files.
This behaviour of android seems slightly strange!
Any help is much appreciated.
In first place, why android sets different permissions for different files, though the files are created using the same code?
Related
I read this post which seems to explain this feature. But, I still don't know few things:
In my file explorer:
When should I ask for this permission
How do I ask (I know the intent->onActivityResult but, how do I check if I have to ask ?)
What do I do when I want to do something with this SDCard permission ?
Thanks in advance
Acolleague just pointed me at this issue. What's the problem exactly? I see in the code that the manifest has:
It also needs the READ_* permission likely. That should give it full access to external storage. Storage Access Framework is a completely different system for interacting with user documents across apps, has nothing specifically to do with write access to sdcard.
And you've always needed that permission to read/write sdcard without root. Old apps didn't have it. The change in KK is that you can now read/write to your private data folder on sdcard WITHOUT needing the permission -- you only need it if you want to touch outside your private data.
So is the real problem that syncthing doesn't USE external storage (sounds confusing, but it only has the WRITE permission), doesn't expose it to the user as a target, or is there simply a bug under the hood somewhere...
Hope that helps!
I am creating an Android app for blocking contact numbers on android . I am stuck in AndroidManifest.xml. Android studio is giving this error while I have an icon.png file in my res/drawable!
image is here.
I have no idea how to turn simple app into system app!image of error is [here].2
Please remove the .png from your manifest file.
You don't need to add the file extension in manifest file
or layout file. Just the name, without the file extension, will do.
So, your entry should look like this:
android:icon="#drawable/icon"
Remove the ".png" from you manifest, you do not define that here. Also: You should provide proper drawables for different display densities. You could e.g. use this online generator to get them Android Assets Studio : Launcher icons
When you want to use the MODIFY_PHONE_STATE permissions your users will most likely need an open bootloader and root to use your app. You can find some instructions here. You can't move apps to /system without mounting system rewritable, which you need root for. Alternative: Users have to use a custom recovery to push the app to /system, which requires an open bootloader at least.
On Android 4.4.2 Environment.getExternalStorageDirectory().getPath() returns /storage/emulated/0 but this path does not exist on my Nexus5 Android 4.4.2. Environment.getExternalStorageDirectory().getPath() worked up until Android 4.4.2.
How can I get the /sdcard path on Android 4.4.2?
This path does not exist on my Nexus5 Android 4.4.2.
Yes, it does, for your process at runtime.
For example, this sample project downloads a file to Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS). If you log the location at runtime, when running it on a Nexus 5, it is reported as /storage/emulated/0/Download. And the download succeeds.
If you are looking for /storage/emulated/0 via DDMS or adb shell, you will not find it. For those tools, default external storage is /mnt/shell/emulated/0. Hence, the downloaded file from the above sample appears in the /mnt/shell/emulated/0/Download directory.
AFAIK, the difference is tied to providing separate external storage to secondary accounts.
The Storage Options documentation says to use Environment.getExternalStorageDirectory() (as you are already correctly using). This function is available on all versions of Android.
Are you seeing it return a path that isn't actually available on a 4.2 device?
Please note (from Environment.getExternalStorageDirectory()):
Applications should not directly use this top-level directory, in order to avoid polluting the user's root namespace. Any files that are private to the application should be placed in a directory returned by Context.getExternalFilesDir, which the system will take care of deleting if the application is uninstalled. Other shared files should be placed in one of the directories returned by getExternalStoragePublicDirectory(String).
Writing to this path requires the WRITE_EXTERNAL_STORAGE permission, and starting in read access requires the READ_EXTERNAL_STORAGE permission, which is automatically granted if you hold the write permission.
Starting in KITKAT, if your application only needs to store internal data, consider using getExternalFilesDir(String) or getExternalCacheDir(), which require no permissions to read or write.
Sometimes /storage/emulated/0 can be written to, but reads fail... so tests for "writability" are not sufficient. This is such an annoying problem, I have come up with an equally annoying but effective solution.
Hardcode "/mnt/sdcard" Yea, I said it.
Looks like someone else said it first ... storing android application data on SD Card
More joy... http://forums.bignerdranch.com/viewtopic.php?f=414&t=7407
How exactly does one go about such a simple thing in this beautifully over-complicated framework?
Yes I've read the documentation on Data Storage for Android, about 54.5 times. But I can not find anyplace where the documentation describes how you should go about placing files on the external storage at compile time.
Here's what I want to do: I want to include a couple of (big) (10-20mb) audio files in my application. Naturally, I do not want these to be stored on the internal storage, because they're just too big. So placing them in res/raw is not an option (because, if I understand correctly, things in res/raw will be placed in the internal storage of the phone, correct?)
The documentation only states that "if you want to store static files at compile time, use res/raw". Now if Android is smart enough to place those files on the external storage all by itself then I'm forever greatful.. But somehow I doubt that. All help is appreciated :)
(Sorry if it seems like I have an attitude, I've just spent way too much time on something so simple)
Thanks again :)
UPDATE: I ended up downloading the files from the application instead of including them at install-time. Thanks for the help guys!
I hit a problem while trying to download through a url, spent a lot of time trying to get it to work, and in the end the problem was because I hadn't declared the correct permission in the android manifest file! So to anyone who's looking to download stuff in their apps, do not forget to set the permissions in the android manifest, here are the permissions I needed:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
<uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>
Place these above the start of the tag
If your large files are in the APK, they'll be stored wherever the APK gets stored - this can be internal or external, and it seems that this is not what you want. The most likely option for you seems to be to place the files on a web site and during the first run of your application, it must notice that the files do not exist and retrieve them post-installation.
how you should go about placing files on the external storage at compile time.
I'm assuming the above is a typo and you mean at install time.
As for your requirement - it's not possible to instruct the Android Application Manager to unpack different parts of an APK to different places during the installation.
Further to this, there's no guarantee that an APK download will go to the internal or external memory storage (where it will stay unless otherwise deleted).
And even further to this, there's no guarantee that even if a device has external storage, it will be available at installation time or have enough free space.
At this point I wonder about audio files which are 10-20MB in size - either they're very long (in duration) or they're encoded at a high bit-rate. If it's the latter then this doesn't make too much sense as most mobile devices have fairly poor audio reproduction (in relative terms)....just some thoughts to mull over.
I personally think mah's suggestion of downloading post-installation may be a better approach but my comments about availability of external storage still hold true.
Proper approach to solving your problem on Android is "don't put them with your application". Just download them on first start from your web server (using HTTP client API) or, if these files will be upgraded independently of the application itself, prepare them as a separate "application" for the user to download via Market.
I am writing an app to monitor some files under /sys/devices/.../cpu. There is one file that is owned by root:root, with only read permissions for root.
I added code to exec("su"), but even then I get a file not found exception. The only way I don't get an error is if I chmod the file permissions. However, these permissions get set back to root read after boot, so I'd really like to find how to do the read without changing the file perms.
Thanks,
Jim
I was able to do this following the code here: http://code.google.com/p/market-enabler/source/browse/branches/MarketAccess/src/ru/org/amip/MarketAccess/utils/ShellInterface.java. Jim