[android-developers] How To Access Device Internal Storage?

2012-05-11 Thread JediDroid

Hello,

I know the "if statement" section of the code below is successful for 
accessing the sd card when its mounted.

Please tell me what code to use in the "else if statement" section to 
access device internal storage (internal flash storage)?

My code:

String state = Environment.getExternalStorageState();

if (Environment.MEDIA_MOUNTED.equals(state)) {

// Try to make directory on the SDcard.
subdirectory = Environment.getExternalStoragePublicDirectory("MyDirectory");

// Make sure the directory exists.
subdirectory.mkdirs();

} else if (-- *What code to use here to access device internal storage? *--) 
{

// *What code to use below to access device internal 
storage?*

// *Is this the correct code to make a directory on device internal storage?
*
subdirectory = Environment.getExternalStoragePublicDirectory("MyDirectory");

// Make sure the directory exists.
subdirectory.mkdirs();
  
} else {}


*Reference to using the methods:* 
getExternalStorageState()  and  getExternalStoragePublicDirectory()
http://developer.android.com/reference/android/os/Environment.html#getExternalStorageState()


Thank you for your help.


-- 
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] How To Access Device Internal Storage?

2012-05-11 Thread Mark Murphy
getFilesDir(), I suppose.

On Fri, May 11, 2012 at 2:21 PM, JediDroid  wrote:
>
> Hello,
>
> I know the "if statement" section of the code below is successful for
> accessing the sd card when its mounted.
>
> Please tell me what code to use in the "else if statement" section to access
> device internal storage (internal flash storage)?
>
> My code:
>
> String state = Environment.getExternalStorageState();
>
> if (Environment.MEDIA_MOUNTED.equals(state)) {
>
> // Try to make directory on the SDcard.
> subdirectory = Environment.getExternalStoragePublicDirectory("MyDirectory");
>
> // Make sure the directory exists.
> subdirectory.mkdirs();
>
> } else if (-- What code to use here to access device internal storage? --) {
>
>                 // What code to use below to access device internal storage?
>
> // Is this the correct code to make a directory on device internal storage?
> subdirectory = Environment.getExternalStoragePublicDirectory("MyDirectory");
>
> // Make sure the directory exists.
> subdirectory.mkdirs();
>
> } else {}
>
>
> Reference to using the methods:
> getExternalStorageState()  and  getExternalStoragePublicDirectory()
> http://developer.android.com/reference/android/os/Environment.html#getExternalStorageState()
>
>
> Thank you for your help.
>
>
> --
> 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



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

Android Training in DC: http://marakana.com/training/android/

-- 
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] How To Access Device Internal Storage?

2012-05-11 Thread JediDroid
Mark,

Thank you for your comment.

I should have clarified what I'm trying to do.

As part of an app I'm developing it will store *User Created files* on the 
SD card if it is available.
If the SD card is not available, it will store the files on the devise 
Internal Flash if it is available. Also, these User Created files must be 
stored in a location where they will not be deleted by the system when the 
app is uninstalled,.

The Android Dev Guide tells me to store files in one of the public 
directories on the external storage. But I am confused on what code to use 
to access the devise internal storage.

I'm developing this app using API Level 8.

Please see the reference information below at this link: *
http://developer.android.com/guide/topics/data/data-storage.html*

*Saving files that should be shared*
If you want to save files that are not specific to your application and 
that should not be deleted when your application is uninstalled, save them 
to one of the public directories on the external storage.

See:  getExternalStorageState()
See:  getExternalStoragePublicDirectory()


Thanks for your help.


On Friday, May 11, 2012 11:23:24 AM UTC-7, Mark Murphy (a Commons Guy) 
wrote:
>
> getFilesDir(), I suppose. 
>
> On Fri, May 11, 2012 at 2:21 PM, JediDroid wrote: 
> > 
> > Hello, 
> > 
> > I know the "if statement" section of the code below is successful for 
> > accessing the sd card when its mounted. 
> > 
> > Please tell me what code to use in the "else if statement" section to 
> access 
> > device internal storage (internal flash storage)? 
> > 
> > My code: 
> > 
> > String state = Environment.getExternalStorageState(); 
> > 
> > if (Environment.MEDIA_MOUNTED.equals(state)) { 
> > 
> > // Try to make directory on the SDcard. 
> > subdirectory = 
> Environment.getExternalStoragePublicDirectory("MyDirectory"); 
> > 
> > // Make sure the directory exists. 
> > subdirectory.mkdirs(); 
> > 
> > } else if (-- What code to use here to access device internal storage? 
> --) { 
> > 
> > // What code to use below to access device internal 
> storage? 
> > 
> > // Is this the correct code to make a directory on device internal 
> storage? 
> > subdirectory = 
> Environment.getExternalStoragePublicDirectory("MyDirectory"); 
> > 
> > // Make sure the directory exists. 
> > subdirectory.mkdirs(); 
> > 
> > } else {} 
> > 
> > 
> > Reference to using the methods: 
> > getExternalStorageState()  and  getExternalStoragePublicDirectory() 
> > 
> http://developer.android.com/reference/android/os/Environment.html#getExternalStorageState()
>  
> > 
> > 
> > Thank you for your help. 
> > 
> > 
> > -- 
> > 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 
>
>
>
> -- 
> Mark Murphy (a Commons Guy) 
> http://commonsware.com | http://github.com/commonsguy 
> http://commonsware.com/blog | http://twitter.com/commonsguy 
>
> Android Training in DC: http://marakana.com/training/android/ 
>

-- 
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] How To Access Device Internal Storage?

2012-05-11 Thread Mark Murphy
On Fri, May 11, 2012 at 4:12 PM, JediDroid  wrote:
> If the SD card is not available, it will store the files on the devise
> Internal Flash if it is available. Also, these User Created files must be
> stored in a location where they will not be deleted by the system when the
> app is uninstalled,.

That is not possible, sorry. Everything on internal storage is removed
when the device is uninstalled.

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

Android Training in DC: http://marakana.com/training/android/

-- 
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] How To Access Device Internal Storage?

2012-05-11 Thread Ken Plumley
Mark,

Is the Android Dev Guide not correct?

The Android Dev Guide makes this claim:
public static File
 getExternalStorageDirectory ()
 Since: API Level
1

Gets the Android external storage directory. This directory may not
currently be accessible if it has been mounted by the user on their
computer, has been removed from the device, or some other problem has
happened. You can determine its current state with
getExternalStorageState()
.

*Note: don't be confused by the word "external" here. This directory can
better be thought as media/shared storage. It is a filesystem that can hold
a relatively large amount of data and that is shared across all
applications (does not enforce permissions). Traditionally this is an SD
card, but it may also be implemented as built-in storage in a device that
is distinct from the protected internal storage and can be mounted as a
filesystem on a computer.*

In devices with multiple "external" storage directories (such as both
secure app storage and mountable shared storage), this directory represents
the "primary" external storage that the user will interact with.

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


On Fri, May 11, 2012 at 1:12 PM, JediDroid wrote:

> Mark,
>
> Thank you for your comment.
>
> I should have clarified what I'm trying to do.
>
> As part of an app I'm developing it will store *User Created files* on
> the SD card if it is available.
> If the SD card is not available, it will store the files on the devise
> Internal Flash if it is available. Also, these User Created files must be
> stored in a location where they will not be deleted by the system when the
> app is uninstalled,.
>
> The Android Dev Guide tells me to store files in one of the public
> directories on the external storage. But I am confused on what code to use
> to access the devise internal storage.
>
> I'm developing this app using API Level 8.
>
> Please see the reference information below at this link: *
> http://developer.android.com/guide/topics/data/data-storage.html*
>
> *Saving files that should be shared*
> If you want to save files that are not specific to your application and
> that should not be deleted when your application is uninstalled, save them
> to one of the public directories on the external storage.
>
> See:  getExternalStorageState()
> See:  getExternalStoragePublicDirectory()
>
>
> Thanks for your help.
>
>
> On Friday, May 11, 2012 11:23:24 AM UTC-7, Mark Murphy (a Commons Guy)
> wrote:
>
>> getFilesDir(), I suppose.
>>
>> On Fri, May 11, 2012 at 2:21 PM, JediDroid wrote:
>> >
>> > Hello,
>> >
>> > I know the "if statement" section of the code below is successful for
>> > accessing the sd card when its mounted.
>> >
>> > Please tell me what code to use in the "else if statement" section to
>> access
>> > device internal storage (internal flash storage)?
>> >
>> > My code:
>> >
>> > String state = Environment.**getExternalStorageState();
>> >
>> > if (Environment.MEDIA_MOUNTED.**equals(state)) {
>> >
>> > // Try to make directory on the SDcard.
>> > subdirectory = 
>> > Environment.**getExternalStoragePublicDirect**ory("MyDirectory");
>>
>> >
>> > // Make sure the directory exists.
>> > subdirectory.mkdirs();
>> >
>> > } else if (-- What code to use here to access device internal storage?
>> --) {
>> >
>> > // What code to use below to access device internal
>> storage?
>> >
>> > // Is this the correct code to make a directory on device internal
>> storage?
>> > subdirectory = 
>> > Environment.**getExternalStoragePublicDirect**ory("MyDirectory");
>>
>> >
>> > // Make sure the directory exists.
>> > subdirectory.mkdirs();
>> >
>> > } else {}
>> >
>> >
>> > Reference to using the methods:
>> > getExternalStorageState()  and  **getExternalStoragePublicDirect**ory()
>>
>> > http://developer.android.com/**reference/android/os/**Environment.html#
>> **getExternalStorageState()
>> >
>> >
>> > Thank you for your help.
>> >
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups "Android Developers" g

Re: [android-developers] How To Access Device Internal Storage?

2012-05-11 Thread Mark Murphy
On Fri, May 11, 2012 at 4:30 PM, Ken Plumley  wrote:
> Is the Android Dev Guide not correct?
>
> The Android Dev Guide makes this claim:
>
> public static File getExternalStorageDirectory ()

That is external storage. That is not internal storage.

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

Android Training in DC: http://marakana.com/training/android/

-- 
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] How To Access Device Internal Storage?

2012-05-11 Thread Ken Plumley
Mark,

 Ok, that´s my confusion of the storage terms.

 What code do I use in the "else if statement" section to store files on
the device built-in external storage?

 Thanks.


On Fri, May 11, 2012 at 1:50 PM, Mark Murphy wrote:

> On Fri, May 11, 2012 at 4:30 PM, Ken Plumley wrote:
> > Is the Android Dev Guide not correct?
> >
> > The Android Dev Guide makes this claim:
> >
> > public static File getExternalStorageDirectory ()
>
> That is external storage. That is not internal storage.
>
> --
> Mark Murphy (a Commons Guy)
> http://commonsware.com | http://github.com/commonsguy
> http://commonsware.com/blog | http://twitter.com/commonsguy
>
> Android Training in DC: http://marakana.com/training/android/
>
> --
> 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
>

-- 
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] How To Access Device Internal Storage?

2012-05-11 Thread Mark Murphy
On Fri, May 11, 2012 at 5:12 PM, Ken Plumley  wrote:
> Ok, that´s my confusion of the storage terms.
>
> What code do I use in the "else if statement" section to store files on the
> device built-in external storage?

You already have that code, in the true section of your if statement.

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

Android Training in DC: http://marakana.com/training/android/

-- 
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] How To Access Device Internal Storage?

2012-05-11 Thread Ken Plumley
Mark,

So the code below will work for both the sd card and the device built-in
external storage?

if (Environment.MEDIA_MOUNTED.equals(state)) {

 // Try to make directory on the SDcard or device built-in external storage.
subdirectory = Environment.getExternalStoragePublicDirectory("MyDirectory");

// Make sure the directory exists.
subdirectory.mkdirs();
  } else {}

Thanks.


On Fri, May 11, 2012 at 2:16 PM, Mark Murphy wrote:

> On Fri, May 11, 2012 at 5:12 PM, Ken Plumley  wrote:
> > Ok, that´s my confusion of the storage terms.
> >
> > What code do I use in the "else if statement" section to store files on
> the
> > device built-in external storage?
>
> You already have that code, in the true section of your if statement.
>
> --
> Mark Murphy (a Commons Guy)
> http://commonsware.com | http://github.com/commonsguy
> http://commonsware.com/blog | http://twitter.com/commonsguy
>
> Android Training in DC: http://marakana.com/training/android/
>
> --
> 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
>

-- 
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] How To Access Device Internal Storage?

2012-05-11 Thread Mark Murphy
On Fri, May 11, 2012 at 5:30 PM, Ken Plumley  wrote:
> So the code below will work for both the sd card and the device built-in
> external storage?

There is only one thing designated "external storage" per device. What
it is (SD card, on-board flash, 3.5" floppy disk, wafer tape/stringy
floppy/micro drive, lots and lots of tiny punch cards, whatever) is up
to the manufacturer. From the SDK's standpoint, "the sd card and the
device built-in external storage" are the same thing, for devices that
use the SD card as external storage. For devices that do not, from the
SDK's standpoint "the sd card" does not exist.

:: insert obligatory thread from others ranting about how Google is
teh evil for not supporting N forms of external storage ::

However, getExternalStoragePublicDirectory() does not take an
arbitrary string as a parameter. It should be one of the documented
DIRECTORY_ constants on Environment.

If you are seeking a directory unique for your own app on external
storage, use getExternalFilesDir() (available on all subclasses of
Context, such as Activity) instead of
getExternalStoragePublicDirectory().

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

Android Training in DC: http://marakana.com/training/android/

-- 
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] How To Access Device Internal Storage?

2012-05-11 Thread Ken Plumley
Mark,

How does the user access the sd card and the internal device built-in
external storage in a device like this Motorola TRIUMPH? It has sd card and
internal ( built-in external storage).

Motorola TRIUMPH specifications


   - Internal Memory: 2GB
   - Expandable Memory: 32GB
   - RAM: 512MB


http://www.virginmobileusa.com/cell-phones/motorola-triumph-phone.jsp









On Fri, May 11, 2012 at 2:38 PM, Mark Murphy wrote:

> On Fri, May 11, 2012 at 5:30 PM, Ken Plumley  wrote:
> > So the code below will work for both the sd card and the device built-in
> > external storage?
>
> There is only one thing designated "external storage" per device. What
> it is (SD card, on-board flash, 3.5" floppy disk, wafer tape/stringy
> floppy/micro drive, lots and lots of tiny punch cards, whatever) is up
> to the manufacturer. From the SDK's standpoint, "the sd card and the
> device built-in external storage" are the same thing, for devices that
> use the SD card as external storage. For devices that do not, from the
> SDK's standpoint "the sd card" does not exist.
>
> :: insert obligatory thread from others ranting about how Google is
> teh evil for not supporting N forms of external storage ::
>
> However, getExternalStoragePublicDirectory() does not take an
> arbitrary string as a parameter. It should be one of the documented
> DIRECTORY_ constants on Environment.
>
> If you are seeking a directory unique for your own app on external
> storage, use getExternalFilesDir() (available on all subclasses of
> Context, such as Activity) instead of
> getExternalStoragePublicDirectory().
>
> --
> Mark Murphy (a Commons Guy)
> http://commonsware.com | http://github.com/commonsguy
> http://commonsware.com/blog | http://twitter.com/commonsguy
>
> Android Training in DC: http://marakana.com/training/android/
>
> --
> 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
>

-- 
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] How To Access Device Internal Storage?

2012-05-11 Thread Mark Murphy
On Fri, May 11, 2012 at 6:12 PM, Ken Plumley  wrote:
> How does the user access the sd card and the internal device built-in
> external storage in a device like this Motorola TRIUMPH? It has sd card and
> internal ( built-in external storage).

The device manufacturer will choose one to be "external storage" as
defined by the SDK. There is nothing in the SDK to find out about the
other one.

:: insert obligatory thread from others discussing using console apps
to examine mountpoints and other incompatible techniques ::

*Users* may have the ability to work with the other one by means
supplied by the device manufacturer (e.g., both showing up as
mountable drives).

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

Android Training in DC: http://marakana.com/training/android/

-- 
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] How To Access Device Internal Storage?

2012-05-11 Thread Ken Plumley
Mark,

Thanks for clarifying this multiple "external storage" issue. It has been
confusing me on how to store files on two external storage areas.

Thanks again.



On Fri, May 11, 2012 at 3:36 PM, Mark Murphy wrote:

> On Fri, May 11, 2012 at 6:12 PM,  wrote:
> > How does the user access the sd card and the internal device built-in
> > external storage in a device like this Motorola TRIUMPH? It has sd card
> and
> > internal ( built-in external storage).
>
> The device manufacturer will choose one to be "external storage" as
> defined by the SDK. There is nothing in the SDK to find out about the
> other one.
>
> :: insert obligatory thread from others discussing using console apps
> to examine mountpoints and other incompatible techniques ::
>
> *Users* may have the ability to work with the other one by means
> supplied by the device manufacturer (e.g., both showing up as
> mountable drives).
>
> --
> Mark Murphy (a Commons Guy)
> http://commonsware.com | http://github.com/commonsguy
> http://commonsware.com/blog | http://twitter.com/commonsguy
>
> Android Training in DC: http://marakana.com/training/android/
>
> --
> 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
>

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