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 8658037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:40:08+00:00 2026-06-12T15:40:08+00:00

I have an application that creates a configuration file and a log file. I

  • 0

I have an application that creates a configuration file and a log file. I stored these in the external storage, but when I try it in my android emulator it doesn’t work because the external storage isn’t writable. If this happens, where should I store the files?

This is my code:

private void createConfigurationFile(){
    File ssConfigDirectory = 
        new File(Environment.getExternalStorageDirectory()+"/MyApp/config/");
    File file = new File(ssConfigDirectory, mUsername+".cfg");

    if(!file.exists()){
        try{
            String state = Environment.getExternalStorageState();
            if (!Environment.MEDIA_MOUNTED.equals(state)){
                ssConfigDirectory = new File("PATH_WHERE_I_SHOULD_STORE_IT");
            }
            File ssLogDirectory = new File(ssConfigDirectory+"/SweetSyncal/log/");
            ssLogDirectory.mkdirs();                
            ssConfigDirectory.mkdirs();

            File outputFile = new File(ssConfigDirectory, mUsername+".cfg");                
            FileOutputStream fOut = new FileOutputStream(outputFile);
            OutputStreamWriter osw = new OutputStreamWriter(fOut); 

            writeFile(osw);
            osw.flush();
            osw.close();
        }catch(Exception e){
            e.printStackTrace();
        }
    }
}
  • 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-12T15:40:09+00:00Added an answer on June 12, 2026 at 3:40 pm

    If the file isn’t too big you can save it in the device’s Internal Storage.

    To access the Internal Storage you can use the following method:

    FileOutputStream openFileOutput (String name, int mode)

    (You need an instance of Context to use it)

    Example:

    String FILENAME = "hello_file";
    String string = "hello world!";
    
    FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_PRIVATE);
    fos.write(string.getBytes());
    fos.close();
    

    As to why the code you provided is not working then there are two possibilities:

    1. You forgot to add the required permission (WRITE_EXTERNAL_STORAGE).
    2. You’r emulator doesn’t have an SD card enabled. Assuming you are using Eclipse you can enabled it in the AVD Manager. Just edit your AVD instance and type in the size of the SD card in the appropriate field. You should also add a hardware feature called SD Card Support and set it to TRUE.

    There is a great article in the official Developer Guide which will tell you everything you need to know about storage in Android.

    You can read it HERE

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

Sidebar

Related Questions

We have a Windows Java desktop application that creates some configuration files at %APPDATA%
I have an application that creates invalid Directories... e.g. c:\Program Files\somedirectory. - the period
I have created an application that creates bar graph based on inputs read from
I have application that brings response via Ajax and creates 5-20 new jQuery click
I have a .Net application that dynamically creates a small HTML page and pops
Today we have a windows application that, using an OCX, creates a web page
I have a service application that on startup reads an XML file and starts
I have an application that needs updating constantly. I would like to create a
I have created an application that connect on a web-server and reads an xml
I have created an application that uses settings.settings to store some user specific settings

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.