Android emulator sdcard permisisons not working - android

I've read many posts about this but nothing seems to solve the problem.
I've created a simple app that basically consists of:
Log.d("RSE", Environment.getExternalStorageState());
Log.d("RSE", "Readable? " + Environment.getExternalStoragePublicDirectory("Movies").canRead());
It always says mounted and Readable? false
When I try to do anything more, I get a permission denied error.
I've added
<uses-permission android:name="ANDROID.PERMISSION.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="ANDROID.PERMISSION.READ_EXTERNAL_STORAGE" />
inside AndroidManifest.xml inside the <manifest> tag and before the <application> tag.

Depending on the device, I've personally found Environment.getExternalStorage*() to be unreliable in what it points to. In this case, it's probably pointing to the emulated storage which doesn't seem to like I/O. I ended up just using "/sdcard/Movies/" which worked far more reliably than Environment.getExternalStoragePublicDirectory("Movies") ever did.

I have no idea why but I recreated the AVD and now its readable.

Related

Not able to create directory for SharedPreferences or DataBase

We're having a crash when starting the app and it tries to create the shared preferences and read from the database. It happens in different devices, mostly HTCs but also LGs, that are running Gingerbread, and they are not rooted.
E/ApplicationContext(2630): Couldn't create directory for SharedPreferences file /data/data/com.example.project/shared_prefs/com.example.project_preferences.xml
E/Database(2630): sqlite3_open_v2("/data/data/com.example.project/databases/project.db", &handle, 6, NULL) failed
We're initializing SharedPreferences with Roboguice.
Uninstalling the app and re-installing it seems to help, but we don't have a way to say that to our users.
I've looked around and found that people usually have this problem in rooted devices or in specific Samsung devices.
Thanks in advance!
Note: our real package name is unique, I've changed it on the code above so it's not public.
You need to add the permissions in your AndroidManifest.xml:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
I have the same problem with you, and I solved it with the above solution. I think you must forget the permissions, too. Try it.
I would suggest that you change the package name of your application from com.example.project to something more unique. Probably the users who have this problem have another application installed on their device using the same package name, thereby causing a conflict.

What are the permission need to live wallpaper?

What are the permissions I need in order to set a live wallpaper and get the gallery images?
you want to give two permission
android:name="android.software.live_wallpaper" />
android:permission="android.permission.BIND_WALLPAPER">
For live wallpaper, place the below in your service tag in manifest.xml.
android:permission="android.permission.BIND_WALLPAPER
android:name="android.software.live_wallpaper
And for Gallery, here is the link.
Which are the permission i given to set live wallpaper and i cant get
gallery images
If your questions are interconnected, then permissions have nothing to do with you not being able to get gallery images
If these are two independent questions, I would suggest:
Start with a good tuturial. For example: http://www.vogella.com/articles/AndroidLiveWallpaper/article.html
Post the a separate question regarding getting gallery images in your app.
Anyway, to answer the question about permissions alone, depending on how you configure your application,
<uses-feature android:name="android.software.live_wallpaper" />
<uses-permission android:name="android.permission.BIND_WALLPAPER" />
Why I say depending on how you confihure your application is beacuse of this. If you look at the Vogella tutorial linked, the permission android:permission="android.permission.BIND_WALLPAPER" > is declared in the service in the application attribute.
If you look at this tutorial: http://www.codeproject.com/Articles/108390/How-To-Create-Android-Live-Wallpaper, it has the permission set to the application tag.
Here is (yet) another tutorial: http://mobile.tutsplus.com/tutorials/android/creating-live-wallpapers-on-android/

Android getExternalCacheDir() returns null

I am trying to implement the best practices described in Loading Bitmaps effeciently
I've run into trouble because this line:
Utils.getExternalCacheDir(context)
inside of DiskLruCache.java is returning null, which means I get NullPointerException when I try to call .getPath()
Despite the somewhat cryptic NullPointerException that gets thrown the actual issues is that my application did not have WRITE_EXTERNAL permission, so the system was rejecting my attempt to use the ExternalDir for caching. Unfortunately this was happening at a low enough level in the code used in Displaying Bitmaps Effeciently that the Exception does not indicate SecurityException as it normally would if one were trying to write to the SD card without the proper permission.
To fix simply add this:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
to your manifest.
This can also happen if you're running on a device or emulator without any external storage.

Why does accessing Android MediaStore, using MonoDroid, generate UnauthorizedAccessException?

When I attempt to use the solution presented on SO here for dealing with large bitmaps in Android, I get an UnauthorizedAccessException at the point I'm trying to read from the file system from a location such as:
/mnt/sdcard/DCIM/Camera/IMG_20111223_122513.jpg
Is there a particular permission in my manifest I was supposed to select, or something else going on?
Well, there is always this one:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
If you're looking to display a screen-sized version of a full-resolution photograph, may I please refer you to the Android Training article on this subject.

What are the contents of logcat file?

I have to parse the logcat output for my android application.So i wanted to know logcat content. I surfed a lot but i don't a proper answer. what are the logcat contents and when the system writes the logcat file?
Thanks
Pushpa
There's no api that I know of to read the logcat directly into your program. The easiest thing to do is to run logcat externally from your app and collect the results. One example of how to do that is here (see LogcatProcessor.java). Another, more elaborate, version is here (see SendLogActivity.java).
You will need this line in your manifest:
<uses-permission android:name="android.permission.READ_LOGS" />

Categories

Resources