How do I write a byte array to a file in Android?
This is my code for creating the file.
public void writeToFile(byte[] array)
{
try
{
String path = "/data/data/lalallalaa.txt";
FileOutputStream stream = new FileOutputStream(path);
stream.write(array);
} catch (FileNotFoundException e1)
{
e1.printStackTrace();
}
}
When I try to send a file to my server just by calling the path String path = "/data/data/lalallalaa.txt";
I am getting a logcat error:
03-26 18:59:37.205: W/System.err(325): java.io.FileNotFoundException: /data/data/lalallalaa.txt
I don't understand why it can't find the file that it "supposedly" has already been created.
+3
source to share
4 answers