0

I want to save my internal storage file into the folder create by my app . Please some one suggest me how it is possible. My Code :

 File sub = new File("/sdcard/myfiles"); sub.mkdirs(); FileOutputStream fout; try { fout = openFileOutput("MyPrefs" ,Context.MODE_PRIVATE); String data="Welcome to Android Internal Storage"; fout.write(data.getBytes()); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } 

1 Answer 1

1

Try this to save:

//write file File log = new File("sdcard/MyDirectory/MyFile.txt"); try { if (!log.exists()) { //System.out.println("We had to make a new file."); log.createNewFile(); } FileWriter fileWriter = new FileWriter(log, true); BufferedWriter bufferedWriter = new BufferedWriter(fileWriter); bufferedWriter.write("dataaaa"+ "%" + "moreDataaa"+ "%" + "moreMoreDataaa"); bufferedWriter.write("******************** " + "\n"); bufferedWriter.close(); //System.out.println("Done"); } catch (IOException e) { //System.out.println("COULD NOT LOG!!"); } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.