[android-developers] Re: Problem while creating a new file

2008-12-30 Thread Ashok Kumar
HI,I got it working by adding createNewFile also. Now I am able to create a
new text file.

File testFile = new File(this.getCacheDir(),aaa.txt);
testFile.createNewFile();
if (!testFile.exists()) {
  System.out.println(--File does not exist: );
}



On Tue, Dec 30, 2008 at 12:11 PM, Ashok Kumar vak...@gmail.com wrote:

 hi,Thanks for your quick responses

 Now iam trying to create new file in the below ways:  Still Iam not able to
 create the file

 1)
 File testFile = new File(this.getCacheDir(),aaa.txt);
 if (!testFile.exists()) {
   System.out.println(--File does not exist: );
 }


 2)
 String filePath1 = this.getCacheDir()+/blahC.txt;
 File testFile = new File(filePath1);
 if (!testFile.exists()) {
   System.out.println(--File does not exist: );
 }

 In either of the above two cases  File is not getting created.

 But if I use createTempFile... file is getting created in the CacheDir
 temp = File.createTempFile(aaa, .txt, this.getCacheDir());

 The SDK version I am using is android-sdk-windows-1.0_r1


 On Mon, Dec 29, 2008 at 7:37 PM, sarwees hashimisa...@gmail.com wrote:


 Ashok,

 you will not be able to create files to the /data directory since that
 is a system level directory. You can, however, create files within
 your application's data directory. Get a reference to the Context and
 use the cache directory (getCacheDir()) or the files directory
 (getFilesDir()).

 On Dec 29, 4:36 am, Ashok Kumar vak...@gmail.com 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Problem while creating a new file

2008-12-29 Thread roland

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 vak...@gmail.com 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Problem while creating a new file

2008-12-29 Thread sarwees

Ashok,

you will not be able to create files to the /data directory since that
is a system level directory. You can, however, create files within
your application's data directory. Get a reference to the Context and
use the cache directory (getCacheDir()) or the files directory
(getFilesDir()).

On Dec 29, 4:36 am, Ashok Kumar vak...@gmail.com 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Problem while creating a new file

2008-12-29 Thread Ashok Kumar
hi,Thanks for your quick responses

Now iam trying to create new file in the below ways:  Still Iam not able to
create the file

1)
File testFile = new File(this.getCacheDir(),aaa.txt);
if (!testFile.exists()) {
  System.out.println(--File does not exist: );
}


2)
String filePath1 = this.getCacheDir()+/blahC.txt;
File testFile = new File(filePath1);
if (!testFile.exists()) {
  System.out.println(--File does not exist: );
}

In either of the above two cases  File is not getting created.

But if I use createTempFile... file is getting created in the CacheDir
temp = File.createTempFile(aaa, .txt, this.getCacheDir());

The SDK version I am using is android-sdk-windows-1.0_r1


On Mon, Dec 29, 2008 at 7:37 PM, sarwees hashimisa...@gmail.com wrote:


 Ashok,

 you will not be able to create files to the /data directory since that
 is a system level directory. You can, however, create files within
 your application's data directory. Get a reference to the Context and
 use the cache directory (getCacheDir()) or the files directory
 (getFilesDir()).

 On Dec 29, 4:36 am, Ashok Kumar vak...@gmail.com 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---