[android-developers] Re: on sdcard, File.canRead() = true, File.canWrite() = false

2010-08-10 Thread Bob Kerns
Ah, yes, of course. That critical fact slipped my mind -- thanks
Dianne!

This is, of course, a major reason why ability to write to the SD card
is controlled by an application permission.

Even without the limitations of FAT, file ownership is a tenuous
concept with removable media. I have scripts to set up EC2 instances,
and I have to force user UIDs in each created, so that the filesystems
I mount on those instances can be consistent. And that's using the
ext3 filesystem.

On Aug 9, 3:25 pm, Dianne Hackborn hack...@android.com wrote:
 You can't change the permissions on stuff in external storage.  That uses a
 FAT filesystem, which doesn't have permissions, so all files there simply
 immutably use the permissions of the mount point.

-- 
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: on sdcard, File.canRead() = true, File.canWrite() = false

2010-08-09 Thread Bob Kerns
Kostya and Mark answered your main question; I'll address your ps.

Applications are indeed 'other' in the permissions you list below, but
applications do have their own uids, so an Application's directory
will be owned by its uid.

An application with the right permission I'm guessing is put into the
sdcard_rw group, and thus would come in under the group permissions
instead.

I believe chmod command doesn't take the symbolic arguments -- you'll
have to use the numeric arguments like we did back in the 1970's.

I'm not sure why you were trying to remove the 'other' permissions on
that file, but let's say you did ls -l on it, and the permissions were
-rw-r--r--. You'd convert this to the numeric form: 644. Your o-rwx
would mean 'turn off all the bits in the last digit', so you'd want
chmod 640 ...

I'd love to have a document on the command-line commands!

You can install the busybox toolkit, and get much improved versions of
many commands, such as this. I find a rooted device without busybox to
be very disconcerting. Busybox puts a large number of commands in one
executable to make it quite small, and then symlinks to it under each
command name. It looks at the name to figure which command you're
asking for.

On Aug 9, 10:59 am, john brown johnbrowngreybe...@gmail.com wrote:

 P.S.
 I got a command prompt via c:\Program Files\Android-SDK\tools adb
 shell

 # ls -l /sdcard/Android/data/lms
 rwxr-x system    sdcard_rw        63   2010-07-19 15:17
 mpReadAbDdx201006.txt
 rwxr-x system    sdcard_rw     45211   2010-07-19 15:17
 mpTranAbDdx201006.txt

 The way I read this is that the owner's rights are ---, group is rwx,
 others is r-x. I'm just guessing, the application is others?

 But I cannot get chmod to change the attributes, i.e.:

 # chmode o-rwx /sdcard/Android/data/lms/mpReadAbDdx201006.txt
 Bad mode

 (I get the same file attributes when I copy file to sdcard via  DDMS
 File Explorer.)

 Where can I find documentation to the Android linux (?) commands? (I
 mean the command line commands)

-- 
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: on sdcard, File.canRead() = true, File.canWrite() = false

2010-08-09 Thread john brown
SOLVED! THANK YOU Android-Developers group!

Thank you so much for your help. It is wonderful to have someplace to
go for answers.

John Brown

On Aug 9, 11:59 am, john brown johnbrowngreybe...@gmail.com wrote:
 Hello,

 Documentation source 
 http://developer.android.com/guide/topics/data/data-storage.html

 Every Android-compatible device supports a shared external storage
 that you can use to save files. This can be a removable storage media
 (such as an SD card) or an internal (non-removable) storage. Files
 saved to the external storage are world-readable and can be modified
 by the user when they enable USB mass storage to transfer files on a
 computer.

 PROBLEM: I cannot write to a file on the sdcard.
 QUESTION: Is it possible to write to a file on the sdcard?

 If YES, what do I need to do to make File.canWrite = true?

 I am using Android 2.1 update 1, API level 7, Eclipse, and HVGA skin.

 I am running my app / troubleshooting on the Android SDK ADV.

 When the AVD is running, I check settings  sdcard total 49.21MB,
 available 49.07MB.

 Environment.getExternalStorageState() yields  MEDIA_MOUNTED

 getExternalStorageDirectory() to establish the sdcard root directory.

 I copied the files to the sdcard with adb push source destination

 I am able to successfully read other files in that directory.

 psudo code:
 // __
 File fFile = new File(pathFile);
 if (fFile.exists()){ ... // returns true
 if (fFile.canRead()){ ... // returns true
 if (fFile.canWrite()){ ... // returns false
 try{
         FileWriter Fw = new FileWriter(fFile, true);
         BufferedWriter Bw = new BufferedWriter(Fw);
         PrintWriter outPw = new PrintWriter(Bw, true);
         outPw.println(strRec);
         outPw.close();

 }

 catch(IOException ex){
         System.out.println(IO Error -  + ex.toString());
         System.exit(0);

 }

 // 

 System.out shows:
 IO Error - java.io.FileNotFoundException
 but we know the file is there from the preceding checks:
 if (fFile.exists()){ ... // returns true
 if (fFile.canRead()){ ... // returns true

 What do I need to do to make the file writable?
 Or
 I want to write to the file. What am I doing wrong?

 Thanks, John Brown

 P.S.
 I got a command prompt via c:\Program Files\Android-SDK\tools adb
 shell

 # ls -l /sdcard/Android/data/lms
 rwxr-x system    sdcard_rw        63   2010-07-19 15:17
 mpReadAbDdx201006.txt
 rwxr-x system    sdcard_rw     45211   2010-07-19 15:17
 mpTranAbDdx201006.txt

 The way I read this is that the owner's rights are ---, group is rwx,
 others is r-x. I'm just guessing, the application is others?

 But I cannot get chmod to change the attributes, i.e.:

 # chmode o-rwx /sdcard/Android/data/lms/mpReadAbDdx201006.txt
 Bad mode

 (I get the same file attributes when I copy file to sdcard via  DDMS
 File Explorer.)

 Where can I find documentation to the Android linux (?) commands? (I
 mean the command line commands)

-- 
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: on sdcard, File.canRead() = true, File.canWrite() = false

2010-08-09 Thread Dianne Hackborn
You can't change the permissions on stuff in external storage.  That uses a
FAT filesystem, which doesn't have permissions, so all files there simply
immutably use the permissions of the mount point.

On Mon, Aug 9, 2010 at 11:46 AM, Bob Kerns r...@acm.org wrote:

 Kostya and Mark answered your main question; I'll address your ps.

 Applications are indeed 'other' in the permissions you list below, but
 applications do have their own uids, so an Application's directory
 will be owned by its uid.

 An application with the right permission I'm guessing is put into the
 sdcard_rw group, and thus would come in under the group permissions
 instead.

 I believe chmod command doesn't take the symbolic arguments -- you'll
 have to use the numeric arguments like we did back in the 1970's.

 I'm not sure why you were trying to remove the 'other' permissions on
 that file, but let's say you did ls -l on it, and the permissions were
 -rw-r--r--. You'd convert this to the numeric form: 644. Your o-rwx
 would mean 'turn off all the bits in the last digit', so you'd want
 chmod 640 ...

 I'd love to have a document on the command-line commands!

 You can install the busybox toolkit, and get much improved versions of
 many commands, such as this. I find a rooted device without busybox to
 be very disconcerting. Busybox puts a large number of commands in one
 executable to make it quite small, and then symlinks to it under each
 command name. It looks at the name to figure which command you're
 asking for.

 On Aug 9, 10:59 am, john brown johnbrowngreybe...@gmail.com wrote:

  P.S.
  I got a command prompt via c:\Program Files\Android-SDK\tools adb
  shell
 
  # ls -l /sdcard/Android/data/lms
  rwxr-x systemsdcard_rw63   2010-07-19 15:17
  mpReadAbDdx201006.txt
  rwxr-x systemsdcard_rw 45211   2010-07-19 15:17
  mpTranAbDdx201006.txt
 
  The way I read this is that the owner's rights are ---, group is rwx,
  others is r-x. I'm just guessing, the application is others?
 
  But I cannot get chmod to change the attributes, i.e.:
 
  # chmode o-rwx /sdcard/Android/data/lms/mpReadAbDdx201006.txt
  Bad mode
 
  (I get the same file attributes when I copy file to sdcard via  DDMS
  File Explorer.)
 
  Where can I find documentation to the Android linux (?) commands? (I
  mean the command line commands)

 --
 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.comandroid-developers%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en




-- 
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