Note that there are some explanatory texts on larger screens.

plurals
  1. POCreate a file locally on android(not on SD card)
    primarykey
    data
    text
    <p>I am having an issue where I am trying to create a file locally on the android emulator however when I test it the file exists, it doesn't. I do not have access to a physical android device so am using the emulator. Please note I do not want to save the file on the SD card. I am not very familiar with android's file structure so forgive me if my code doesn't make sense. This is the code I am currently using and it doesn't work :( </p> <pre><code>EditText editText = (EditText) findViewById(R.id.editTextName); String sName = editText.getText().toString(); editText = (EditText) findViewById(R.id.editTextEmail); String sEmail = editText.getText().toString(); editText = (EditText) findViewById(R.id.editTextPostal); String sPostal = editText.getText().toString(); File file = new File("/storage/new/test.txt"); FileOutputStream fos; byte[] data = new String("Name: " + sName + " Subject: " + sEmail + " Question: " + sPostal ).getBytes(); OutputStream myOutput; try { myOutput = new BufferedOutputStream(new FileOutputStream(file,true)); myOutput.write(data); myOutput.flush(); myOutput.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } if(file.exists()) { finish(); } </code></pre> <p>Could anyone experienced enough in the area of android development provide me with some sample code or point me in the right direction so I can get this bad boy working? <strong>EDIT:</strong> When I say it doesn't work, I mean the file never gets created.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload