[android-developers] Re: Fail to create a new file on a sdcard

2009-12-09 Thread Teo [GD API Guru]
Have you managed to do that? I'm very interesting in doing this
myself... Something must have happened because what works previously
doesn't anymore and breaks functionality for a lot of users.

On Dec 3, 3:14 am, Tan saurabhtanej...@googlemail.com wrote:
 Hi all

 I have the same problem, the code writes to emulator even if there is
 no permission and does not write to SD card even if there is
 permission WRITE_EXTERNAL_STORAGE.  If it is not possible to write in
 system process then how can i modify my code? Here is the snippet
 that
 writes stuff
 File directory = new File(Environment.getExternalStorageDirectory
 ().getPath() , fingerprint_UC_basement);
                    if (!directory.exists()) {
                            directory.mkdir();
                    }
                    File file = new File(directory.getPath() ,
 filename);
                    if (!file.exists()  directory.exists()){
                            try {
                                file.createNewFile();
                                FileOutputStream fo = new
 FileOutputStream(filename);
                                String a = Size:  + APs.size();
                                fo.write(a.getBytes());
                                for(int i=0; i APs.size(); i++){
                                 String b = APs.get(i).getBSSID() + 
 
 + APs.get(i).getdBm() +   + APs.get(i).getCount();
                                 fo.write(b.getBytes());
                                }
                                fo.close();
                            } catch (IOException e) {
                                    Log.d(TAG,File creation failed
 for
  + file);
                            }
                    }

 Someone also pointed out that its not possible to write to SD card
 through System process, we have to run a separate service for that.
 Can anyone verify that? Thanks

 Tan

 On Nov 12, 11:43 am, lei eirst...@gmail.com wrote:



  Thanks, Mark. It's solved. The permission of WRITE_EXTERNAL_STORAGE is
  required in Android SDK1.6,
  also I find a link describe 
  it:http://developer.android.com/sdk/android-1.6.html

  On Nov 12, 3:44 pm, Mark Murphy mmur...@commonsware.com wrote:

   lei wrote:
I find thefilethat path to Environment.getExternalStorageDirectory()
is not writable, how could I change it?

   Make sure your app has the WRITE_EXTERNAL_STORAGE permission.

   --
   Mark Murphy (a Commons 
   Guy)http://commonsware.com|http://twitter.com/commonsguy

   Android Training in Germany, 18-22 January 2010:http://bignerdranch.com

-- 
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: Fail to create a new file on a sdcard

2009-12-02 Thread Tan
Hi all

I have the same problem, the code writes to emulator even if there is
no permission and does not write to SD card even if there is
permission WRITE_EXTERNAL_STORAGE.  If it is not possible to write in
system process then how can i modify my code? Here is the snippet
that
writes stuff
File directory = new File(Environment.getExternalStorageDirectory
().getPath() , fingerprint_UC_basement);
   if (!directory.exists()) {
   directory.mkdir();
   }
   File file = new File(directory.getPath() ,
filename);
   if (!file.exists()  directory.exists()){
   try {
   file.createNewFile();
   FileOutputStream fo = new
FileOutputStream(filename);
   String a = Size:  + APs.size();
   fo.write(a.getBytes());
   for(int i=0; i APs.size(); i++){
String b = APs.get(i).getBSSID() + 

+ APs.get(i).getdBm() +   + APs.get(i).getCount();
fo.write(b.getBytes());
   }
   fo.close();
   } catch (IOException e) {
   Log.d(TAG,File creation failed
for
 + file);
   }
   }



Someone also pointed out that its not possible to write to SD card
through System process, we have to run a separate service for that.
Can anyone verify that? Thanks

Tan


On Nov 12, 11:43 am, lei eirst...@gmail.com wrote:
 Thanks, Mark. It's solved. The permission of WRITE_EXTERNAL_STORAGE is
 required in Android SDK1.6,
 also I find a link describe 
 it:http://developer.android.com/sdk/android-1.6.html

 On Nov 12, 3:44 pm, Mark Murphy mmur...@commonsware.com wrote:



  lei wrote:
   I find thefilethat path to Environment.getExternalStorageDirectory()
   is not writable, how could I change it?

  Make sure your app has the WRITE_EXTERNAL_STORAGE permission.

  --
  Mark Murphy (a Commons 
  Guy)http://commonsware.com|http://twitter.com/commonsguy

  Android Training in Germany, 18-22 January 2010:http://bignerdranch.com

-- 
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: Fail to create a new file on a sdcard

2009-12-02 Thread Dianne Hackborn
The system process can not access the SD card, period.  And any questions
about code in there should be on android-porting, thanks.

On Wed, Dec 2, 2009 at 5:14 PM, Tan saurabhtanej...@googlemail.com wrote:

 Hi all

 I have the same problem, the code writes to emulator even if there is
 no permission and does not write to SD card even if there is
 permission WRITE_EXTERNAL_STORAGE.  If it is not possible to write in
 system process then how can i modify my code? Here is the snippet
 that
 writes stuff
 File directory = new File(Environment.getExternalStorageDirectory
 ().getPath() , fingerprint_UC_basement);
   if (!directory.exists()) {
   directory.mkdir();
   }
   File file = new File(directory.getPath() ,
 filename);
   if (!file.exists()  directory.exists()){
   try {
   file.createNewFile();
   FileOutputStream fo = new
 FileOutputStream(filename);
   String a = Size:  + APs.size();
   fo.write(a.getBytes());
   for(int i=0; i APs.size(); i++){
String b = APs.get(i).getBSSID() + 
 
 + APs.get(i).getdBm() +   + APs.get(i).getCount();
fo.write(b.getBytes());
   }
   fo.close();
   } catch (IOException e) {
   Log.d(TAG,File creation failed
 for
  + file);
   }
   }



 Someone also pointed out that its not possible to write to SD card
 through System process, we have to run a separate service for that.
 Can anyone verify that? Thanks

 Tan


 On Nov 12, 11:43 am, lei eirst...@gmail.com wrote:
  Thanks, Mark. It's solved. The permission of WRITE_EXTERNAL_STORAGE is
  required in Android SDK1.6,
  also I find a link describe it:
 http://developer.android.com/sdk/android-1.6.html
 
  On Nov 12, 3:44 pm, Mark Murphy mmur...@commonsware.com wrote:
 
 
 
   lei wrote:
I find thefilethat path to Environment.getExternalStorageDirectory()
is not writable, how could I change it?
 
   Make sure your app has the WRITE_EXTERNAL_STORAGE permission.
 
   --
   Mark Murphy (a Commons Guy)http://commonsware.com|
 http://twitter.com/commonsguy
 
   Android Training in Germany, 18-22 January 2010:
 http://bignerdranch.com

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

[android-developers] Re: Fail to create a new file on a sdcard

2009-11-12 Thread lei
I find the file that path to Environment.getExternalStorageDirectory()
is not writable, how could I change it?

On Nov 12, 2:06 pm, lei eirst...@gmail.com wrote:
 I do not know what is cause of failing to create a new file on a
 sdcard of G1, the code is below:

 File temp = File.createTempFile(test, .temp,
 Environment.getExternalStorageDirectory());

 and the permission of sdcard is: d--rwxr-x.

 Also fail if I try using the code below:

 File file = new File(Environment.getExternalStorageDirectory
 (),media.temp);
 file.createNewFile();

 Giving out about Parent directory of file is not writable. Could
 anyone give me a solution of this?

-- 
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: Fail to create a new file on a sdcard

2009-11-12 Thread Mark Murphy
lei wrote:
 I find the file that path to Environment.getExternalStorageDirectory()
 is not writable, how could I change it?

Make sure your app has the WRITE_EXTERNAL_STORAGE permission.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android Training in Germany, 18-22 January 2010: http://bignerdranch.com

-- 
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: Fail to create a new file on a sdcard

2009-11-12 Thread lei
Thanks, Mark. It's solved. The permission of WRITE_EXTERNAL_STORAGE is
required in Android SDK1.6,
also I find a link describe it: 
http://developer.android.com/sdk/android-1.6.html

On Nov 12, 3:44 pm, Mark Murphy mmur...@commonsware.com wrote:
 lei wrote:
  I find the file that path to Environment.getExternalStorageDirectory()
  is not writable, how could I change it?

 Make sure your app has the WRITE_EXTERNAL_STORAGE permission.

 --
 Mark Murphy (a Commons 
 Guy)http://commonsware.com|http://twitter.com/commonsguy

 Android Training in Germany, 18-22 January 2010:http://bignerdranch.com

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