I create and manage file from android application with this code but what I want then its to delete it.
This is the code how I write and read it:
private String readDataFromString()
{
try{
FileInputStream fis = this.openFileInput("encryptedNotePad.txt");
InputStreamReader isr = new InputStreamReader(fis);
char[] inputBuffer = new char[100];
String s = "";
int charRead;
while((charRead = isr.read(inputBuffer)) > 0){
// Convertimos los char a String
String readString = String.copyValueOf(inputBuffer, 0, charRead);
s += readString;
inputBuffer = new char[100];
}
isr.close();
return s;
}catch (IOException ex){
ex.printStackTrace();
}
return null;
}
private void writeDataToString (String data) throws FileNotFoundException {
try{
//FileOutputStream fos = openFileOutput("encryptedNotePad.txt", MODE_PRIVATE);
FileOutputStream fos = this.openFileOutput("encryptedNotePad.txt", MODE_PRIVATE);
OutputStreamWriter osw = new OutputStreamWriter(fos);
// Escribimos el String en el archivo
osw.write(data);
osw.flush();
osw.close();
}catch (IOException ex){
ex.printStackTrace();
}
}
How Can I delete it?
I found this:
File file = new File(selectedFilePath);
boolean deleted = file.delete();
But, I dont know the file path.Whats the file path?