Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9183049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:42:29+00:00 2026-06-17T18:42:29+00:00

Android provides many options for storing data persistently on the device. I have opted

  • 0

Android provides many options for storing data persistently on the device. I have opted for internal storage, so please don’t make suggestions for storing on an SD card. (I’ve seen too many questions about internal storage have answers for SD cards!!)

I would like to create subdirectories in my application’s internal storage directory. I followed this SO answer, reproduced below.

File mydir = context.getDir("mydir", Context.MODE_PRIVATE); //Creating an internal dir;
File fileWithinMyDir = new File(mydir, "myfile"); //Getting a file within the dir.
FileOutputStream out = new FileOutputStream(fileWithinMyDir); //Use the stream as usual to write into the file.

Unfortunately, that’s creating subdirectories with “app_” prefixes. So, from the example, the subdirectory looks like “app_mydir” (not ideal).

The answer to this SO question suggests that you can get rid of the “app_” prefix this way:

m_applicationDir = new File(this.getFilesDir() + "");
m_picturesDir = new File(m_applicationDir + "/mydir");

But I want to write a zip to something like /data/data/com.mypackages/files/mydir/the.zip.

So, in the end, my code looks like this:

File appDir = new File(getApplicationContext().getFilesDir() + "");
File subDir = new File(appDir + "/subDir");
File outFile = new File(subDir, "/creative.zip");

But, this is creating another error: “File does not exist” when I try this:

FileOutputStream fileStream = new FileOutputStream(outFile);

How can I (1) create a subdirectory without the “app_” prefix and (2) write a zip into it?

Also, if my first demand isn’t reasonable, tell me why in the comments! I’m sure “app_” prefix has some meaning that escapes me atm.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T18:42:31+00:00Added an answer on June 17, 2026 at 6:42 pm

    Did you create the directories?

    File appDir = getApplicationContext().getFilesDir();
    File subDir = new File(appDir, "subDir");
    if( !subDir.exists() )
        subDir.mkdir();
    File outFile = new File(subDir, "creative.zip");
    

    Note that you shouldn’t use / anywhere in your app, just in case it changes. If you do want to create your own paths, use File.separator.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed a kernel module (Android) which provides me: PCM 16-bit 48000 Hz
I'm looking to implement my first Android database, but I have so many questions
I have noted in the Android Market that many popular applications have backward compatibility
I have tried many options but my webview does not scrolls vertically as it
I have a android application, that uses many images. and application is to be
Suppose, someone wants to replace the default frontend of an Android device by a
I am new to Android Development, i searched many forums for getting Sqlite database
I know that Android provides a mechanism to allow developers to save and restore
I have developed one Android app in one project with Eclipse - it's structured
When designing an UI, we need to target many android mutations and various screen

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.