[android-developers] Re: mkdir() fails when min sdk version is 4
There is no uses-permission-group tag. Permissions are just for declaring permissions, for help in displaying them to the user. You are right. That was careless of me. I mistakenly used that tag after looking at http://developer.android.com/reference/android/Manifest.permission_group.html Another related question is that the Vibrant has 16 GB as internal storage. But that's where the /sdcard directory is. There is also another replaceable 2GB MicroSD slot. If I want to write to that drive, how do I access it and does Android consider that as external storage as well? The Android SDK currently only supports one external storage, which for devices with both internal media mountable for USB mass storage and an SD card should be the internal media. I guess this means that I can't programatically access the microSD card. The micro SD card shows up as /sdcard/sd. Which I guess is how Samsung did it and shouldn't be depended upon. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: mkdir() fails when min sdk version is 4
Actually, I made a mistake. If I have the uses-sdk in the manifest, no matter what the value, it fails to create the directory. I do have the write_external_storage permission. The code used to work until I upgraded the SDK to 2.1 I think. This used to work till around 2.0 of the sdk. If I create the directory under data/data using File basedirectory = getFileStreamPath(basedir); subdirectory = new File( basedirectory, subdir_0/subdir_1 ); but I don't want the directory to be deleted when the app is uninstalled. The manifest file is as under. ?xml version=1.0 encoding=utf-8? manifest xmlns:android=http://schemas.android.com/apk/res/android; package=test.test android:versionCode=1 android:versionName=1.0 uses-sdk android:minSdkVersion=4/ uses-permission-group android:name=android.permission- group.STORAGE / application android:icon=@drawable/icon android:label=@string/app_name activity android:name=.Test1 android:label=@string/app_name intent-filter action android:name=android.intent.action.MAIN / category android:name=android.intent.category.LAUNCHER / /intent-filter /activity /application /manifest On Sep 12, 2:41 am, Mark Murphy mmur...@commonsware.com wrote: Do you have the WRITE_EXTERNAL_STORAGE permission? On Sat, Sep 11, 2010 at 5:24 PM, milind mili...@gmail.com wrote: The following code works when I either have no min sdk version specified in the app manifest or if it's 5 or greater. But if I set the min sdk level to 4 (Android 1.6) , it fails to create a subdirectory in the sdcard. There is no error. mkdir() or mkdirs() just returns false. String msg; try { String theState = Environment.getExternalStorageState(); if (theState.equals(Environment.MEDIA_MOUNTED)) { File theBasedir = Environment.getExternalStorageDirectory(); File theSubdir = new File(theBasedir, subdir); boolean created = theSubdir.mkdirs(); msg = theSubdir.exists() ? Success : Fail; } else { msg = Invalid State; } } catch (Exception e) { msg = Error - + e; } System.out.println(msg); Am I doing something wrong here? Or is this a bug? I'd prefer not to set the target to 2.1 and min version to 1.6. But right now, I have to set it to 2.0 for it to work. -- Mark Murphy (a Commons Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy Android 2.2 Programming Books:http://commonsware.com/books -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: mkdir() fails when min sdk version is 4
On Sat, Sep 11, 2010 at 6:19 PM, milind mili...@gmail.com wrote: Actually, I made a mistake. If I have the uses-sdk in the manifest, no matter what the value, it fails to create the directory. I do have the write_external_storage permission. The code used to work until I upgraded the SDK to 2.1 I think. This used to work till around 2.0 of the sdk. Are you sure there are no messages in LogCat? -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android 2.2 Programming Books: http://commonsware.com/books -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: mkdir() fails when min sdk version is 4
On Sat, Sep 11, 2010 at 3:19 PM, milind mili...@gmail.com wrote: \ uses-permission-group android:name=android.permission- group.STORAGE / This should be uses-permission -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: mkdir() fails when min sdk version is 4
Thanks Dianne. That was it. It worked as soon as I changed uses-permission-group android:name=android.permission- group.STORAGE / to uses-permission android:name=android.permission.WRITE_EXTERNAL_STORAGE / I had neither in the old code. Probably a tightening of specs in 2.1. I do wonder what the permission group does. I thought that I saw that in some old post and used it. Seems like the correct one since I assumed it would allow me to read/write/rename/delete files on the external storage. Another related question is that the Vibrant has 16 GB as internal storage. But that's where the /sdcard directory is. There is also another replaceable 2GB MicroSD slot. If I want to write to that drive, how do I access it and does Android consider that as external storage as well? On Sep 12, 3:36 am, Dianne Hackborn hack...@android.com wrote: On Sat, Sep 11, 2010 at 3:19 PM, milind mili...@gmail.com wrote: \ uses-permission-group android:name=android.permission- group.STORAGE / This should be uses-permission -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: mkdir() fails when min sdk version is 4
On Sat, Sep 11, 2010 at 9:13 PM, milind mili...@gmail.com wrote: I had neither in the old code. Probably a tightening of specs in 2.1. I do wonder what the permission group does. I thought that I saw that in some old post and used it. Seems like the correct one since I assumed it would allow me to read/write/rename/delete files on the external storage. There is no uses-permission-group tag. Permissions are just for declaring permissions, for help in displaying them to the user. Another related question is that the Vibrant has 16 GB as internal storage. But that's where the /sdcard directory is. There is also another replaceable 2GB MicroSD slot. If I want to write to that drive, how do I access it and does Android consider that as external storage as well? The Android SDK currently only supports one external storage, which for devices with both internal media mountable for USB mass storage and an SD card should be the internal media. -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en