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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:26:44+00:00 2026-05-30T14:26:44+00:00

This is the code I’m using to write a file .name to some folders

  • 0

This is the code I’m using to write a file .name to some folders in path /sdcard/ that with name starts with cimage. Currently I have 4 such folders, 2 of them were created lately. The problem is with these two and affects any folder that I manually add later.

public static void WriteName(ArrayList<String> citem) {
    final String not_writable = "norw";
    for (int i = 0; i < citem.size(); i++) {
        try {
            File root = new File(Environment.getExternalStorageDirectory()
                    .getName() + "/" + citem.get(i));
            File namefile = new File(root, ".name");
            FileReader namereader = new FileReader(namefile);
            BufferedReader in = new BufferedReader(namereader);
            String[] str_array = new String[4];
            str_array[0] = in.readLine();
            str_array[1] = in.readLine();
            str_array[2] = in.readLine();
            str_array[3] = in.readLine();
            Log.d("NameWrite", "line 4: " + str_array[3]);
            if (str_array[3] == null || !str_array[3].equals(not_writable)) {
                FileWriter namewriter = new FileWriter(namefile);
                BufferedWriter out = new BufferedWriter(namewriter);
                out.write(i
                        + "\nCImage_"
                        + (i)
                        + "\nAutogenerated Stub\nnorw\n");
                out.close();
            } else {
                Log.d("NameManager.WriteName", "Skipping " + root
                        + ", norw set");
            }
        } catch (IOException e) {
            Log.e("NameManager.java : ", ("Error!! Not Writable!!"
                    + Environment.getExternalStorageDirectory().getName()
                    + "/" + citem.get(i)));
        }
    }

}

So what happens is that when the method tries to write the last 2 folders it throws an IOException.

02-26 05:42:39.663: D/NameManager.java(5316): Checking for whatever
02-26 05:42:39.671: D/NameManager.java(5316): SDcard mounted RW
02-26 05:42:40.694: D/java.lang.java.lang.String(5316): file (43) :cimages
02-26 05:42:40.694: D/java.lang.java.lang.String(5316): file (76) :cimages_1
02-26 05:42:40.694: D/java.lang.java.lang.String(5316): file (77) :cimageslkj
02-26 05:42:40.694: D/java.lang.java.lang.String(5316): file (81) :cimages_2
02-26 05:42:40.694: D/NameWrite(5316): line 4: norw
02-26 05:42:40.694: D/NameManager.WriteName(5316): Skipping sdcard/cimages, norw set
02-26 05:42:40.702: D/NameWrite(5316): line 4: norw
02-26 05:42:40.702: D/NameManager.WriteName(5316): Skipping sdcard/cimages_1, norw set
02-26 05:42:40.702: E/NameManager.java :(5316): Error!! Not Writable!!sdcard/cimageslkj
02-26 05:42:40.710: E/NameManager.java :(5316): Error!! Not Writable!!sdcard/cimages_2
02-26 05:42:40.725: D/java.lang.java.lang.String(5316): file (77) :cimageslkj

I can find no explanation for this behavior. All other apps can write to those folder in case you are wondering. What might be causing this?

  • 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-05-30T14:26:45+00:00Added an answer on May 30, 2026 at 2:26 pm

    It’s nothing mysterious, I just forgot to add a loop for cases in which .name don’t exist. Adding this loop fixed it.

    ........
    ........
    try {
                    File root = new File(Environment.getExternalStorageDirectory()
                            .getName() + "/" + fsitem.get(i));
                    File namefile = new File(root, ".name");
                    if (!namefile.exists()){
                        namefile.createNewFile();
                    }
                    FileReader namereader = new FileReader(namefile);
                    BufferedReader in = new BufferedReader(namereader);
                    String[] str_array = new String[4];
    ........
    ........
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This code fails when I try to debug it using VC2010: char frd[32]=word-list.txt; FILE
This code does not seem to compile, I just need to write something to
This code is ment to download the source code of an html file but
This code works properly in my localhost. I am using xampp 1.7.3. but when
This code i put it in the HTML page for check the file value,
This code: <% string path = Request.ApplicationPath.ToString(); %> <link href=<%= path %>/Content/Site.css rel=stylesheet type=text/css
This code URL listofFiles = this.getClass().getResource(someDir); File f = new File(listofFiles.toString()); File[] files =
This code in JS gives me a popup saying i think null is a
This code is from Prototype.js . I've looked at probably 20 different tutorials, and
this code always returns 0 in PHP 5.2.5 for microseconds: <?php $dt = new

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.