Douglas Johgn
Douglas Johgn

Reputation: 221

Android create file on internal storage, what am i doing wrong?

        String filename = job_no + ".csv";
        File newfile = new File(this.getFilesDir(), filename);
        try {
            BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(newfile), 64);
            byte[] bb = resultfile.getBytes();
            out.write(bb);
            out.flush();
            out.close();
        } catch (Exception e) {
            Log.d("", e.toString());
        }

What am i doing wrong?, it doesnt show any error messages and doesn't create any files...

i'm checking it with this

  try { 
     String workbook_xml = new Scanner(new File(filename)).useDelimiter("\\Z").next();
     Log.d(workbook_xml, "");  
  } catch (FileNotFoundException e) { 
       Log.d("", "sdfsdfsdfsdf"); 
  }

it comes back as sdfsdfsdfsdf error (FileNotFOund)

Upvotes: 1

Views: 72

Answers (1)

Blackbelt
Blackbelt

Reputation: 157447

you are checking it in the wrong way

new Scanner(new File(filename))

should be

new Scanner(new File(getFilesDir(), filename))

Upvotes: 1

Related Questions