Hi, you can only create new files on your package. That means "data/
data/your package name/tests.txt".
File file = new File("data/data/com.android.createFileTest/test.txt");
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
On 29 déc, 10:36, "Ashok Kumar" <[email protected]> wrote:
> Hi,I am trying to create a new file using the class File.
> Below is my code snippet
>
> File testFile = new File("/data/tests.txt");
> if (!testFile.exists()) {
> System.out.println("--------------File does not exist: ");
>
> }
>
> Initially I don't have the file tests.txt under data path. So, I am trying
> to create it.After creating the file I am making a check is the file exists
> or not. But it is says that file doesn't exist.
> Can any one please help me out or how to create a new file and write data
> into that file.
>
> Thanks
> Ashok.V
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---