Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Can one create a directory in Android?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  10 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Anil  
View profile  
 More options Jan 16 2008, 12:48 pm
From: Anil <anil.r...@gmail.com>
Date: Wed, 16 Jan 2008 09:48:12 -0800 (PST)
Local: Wed, Jan 16 2008 12:48 pm
Subject: Can one create a directory in Android?
as above

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
trickybit  
View profile  
 More options Jan 16 2008, 1:16 pm
From: trickybit <jmack...@gmail.com>
Date: Wed, 16 Jan 2008 10:16:13 -0800 (PST)
Local: Wed, Jan 16 2008 1:16 pm
Subject: Re: Can one create a directory in Android?
I believe it's just: getContextDir( "my/directory/name" ).mkdirs();

On Jan 16, 9:48 am, Anil <anil.r...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
oxonom  
View profile  
 More options Jan 16 2008, 2:11 pm
From: oxonom <phyrum....@sign.ch>
Date: Wed, 16 Jan 2008 11:11:51 -0800 (PST)
Local: Wed, Jan 16 2008 2:11 pm
Subject: Re: Can one create a directory in Android?
short answer: yes

here is an example:
new File(getDataDir() +"/mydirectory").mkdirs();

I have a longer examle at http://oxonom.com/

I don't know anything about getContextDir couldn't find the method in
the docs.

On 16 Jan., 18:48, Anil <anil.r...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
trickybit  
View profile  
 More options Jan 16 2008, 2:39 pm
From: trickybit <jmack...@gmail.com>
Date: Wed, 16 Jan 2008 11:39:40 -0800 (PST)
Local: Wed, Jan 16 2008 2:39 pm
Subject: Re: Can one create a directory in Android?
blast, I screwed that up.

I meant getFileStreamPath( "my/directory/name" ).mkdirs()

seems equivalent to what you provided.

On Jan 16, 11:11 am, oxonom <phyrum....@sign.ch> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
oxonom  
View profile  
 More options Jan 16 2008, 2:52 pm
From: oxonom <phyrum....@sign.ch>
Date: Wed, 16 Jan 2008 11:52:14 -0800 (PST)
Local: Wed, Jan 16 2008 2:52 pm
Subject: Re: Can one create a directory in Android?
well, while looking in the docs, getDataDir is only temporary :-(

it's so easy with Eclipse to type get+[CTRL+SPACE] and using the first
suitable method.

On 16 Jan., 20:39, trickybit <jmack...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
hackbod  
View profile  
 More options Jan 16 2008, 9:09 pm
From: hackbod <hack...@gmail.com>
Date: Wed, 16 Jan 2008 18:09:39 -0800 (PST)
Local: Wed, Jan 16 2008 9:09 pm
Subject: Re: Can one create a directory in Android?
You can use getFileStreamPath() instead of getDataDir(), if you just
want a place to put directories.  In a future SDK there will be a new
set of APIs explicitly for creating directories.

On Jan 16, 11:52 am, oxonom <phyrum....@sign.ch> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Anthony  
View profile  
 More options Jan 17 2008, 8:18 pm
From: Anthony <xjh2...@gmail.com>
Date: Thu, 17 Jan 2008 17:18:00 -0800 (PST)
Subject: Re: Can one create a directory in Android?
Hi All,

I want to create a directory in file system, I run the following code,
but failed:
          try {
               File dir = getFileStreamPath("mydir1");
               if (!dir.mkdirs()) {
                    Log.e(TAG, "Create dir in local failed"); //<--
print this error
                    return;
               }
          } catch (FileNotFoundException e1) {
               Log.e(TAG, "error 1: "+e1.toString());
          }

Could you help me to check what's wrong with me?
Thank you.

On Jan 17, 10:09 am, hackbod <hack...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
trickybit  
View profile  
 More options Jan 22 2008, 1:15 pm
From: trickybit <jmack...@gmail.com>
Date: Tue, 22 Jan 2008 10:15:30 -0800 (PST)
Local: Tues, Jan 22 2008 1:15 pm
Subject: Re: Can one create a directory in Android?
If you are getting your first error message, I believe it means that
the directory already exists.
See docs on: boolean File.mkdirs()

If instead you're seeing your second error message, what error does it
show?

By the way, you don't need to type "toString()" in that call, just
type:  "error 1: "+ e1

On Jan 17, 5:18 pm, Anthony <xjh2...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
trickybit  
View profile  
 More options Jan 22 2008, 1:26 pm
From: trickybit <jmack...@gmail.com>
Date: Tue, 22 Jan 2008 10:26:23 -0800 (PST)
Local: Tues, Jan 22 2008 1:26 pm
Subject: Re: Can one create a directory in Android?
Wow, screwed up in my "correction," too.

It turns out that getFileStreamPath() will not accept path separators
in its argument.

But:
1- the above approach works to create a single-depth subdirectory
(i.e., no slashes).
2- if you want to create deeper subdirectory trees, you can do this:

        File subdirectory = null;
        try {
            File basedirectory = getFileStreamPath( "basedir" );
            subdirectory = new File( basedirectory, "subdir_0/
subdir_1" );
            if ( ! subdirectory.exists() ) {
                Log.i( LOGTAG, "attempt to create subdirectory: " +
subdirectory );
                subdirectory.mkdirs();          // makes all subdir levels you need
            }
        }
        catch ( FileNotFoundException e1 ) {
            Log.e( LOGTAG, "oops 0", e1 );
        }

This will create a subdirectory named (in the current SDK)
    /data/data/<package>/files/basedir/subdir_0/subdir_1

If you provide an empty string to the first getFileStreamPath() call,
you will get
    /data/data/<package>/files/subdir_0/subdir_1

but I'm not sure I'd want to rely on that behavior.
Jim

On Jan 16, 11:39 am, trickybit <jmack...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
oxonom  
View profile  
 More options Jan 23 2008, 4:19 pm
From: oxonom <phyrum....@sign.ch>
Date: Wed, 23 Jan 2008 13:19:26 -0800 (PST)
Local: Wed, Jan 23 2008 4:19 pm
Subject: Re: Can one create a directory in Android?
Thank you, I already updated my source code. In my example, I unpack a
zip file from the apk resource folder to the local application folder
so I can display the html pages with WebKit/WebView.

I too used an empty string to get the files folder.

If anyone care, an Eclipse project folder is available at:
http://oxonom.com/node/17

On Jan 22, 7:26 pm, trickybit <jmack...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »