1

How to format directory in android project folder as jvm can't see datass.txt or sometimes logcat says read only file...(i am putting datass.txt in main project root)

i am passing an array of strings and want to save it to a file datass.txt so i can retrieve data when internet is not connected

public void FileWrite(String[]  temp) throws IOException{
        File m = new File("datass.txt");
     final String[] descs = temp ;
     DataOutputStream out = new DataOutputStream(new
                BufferedOutputStream(
                  new FileOutputStream(m)));


     for (int i = 0; i < 31; i ++) {

            out.writeUTF(descs[i]);

        }
}
1
  • 2
    where is your file? If you are trying to access external files, you may need to add permissions. Commented Feb 19, 2012 at 20:34

2 Answers 2

1

You need to add File Writing Permission in your AndroidManiFest.xml file.

android.permission.WRITE_EXTERNAL_STORAGE

Please visit this link for various other permission set.

Sign up to request clarification or add additional context in comments.

Comments

0

it seems that you could a Index out of bound exception i am not sure but to guard your self change the for loop header to this

for(int i =0; i < descs.length ; ++i)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.