Problem while creating a new file

by Ashok Kumar » Mon, 29 Dec 2008 17:37:06 GMT


Sponsored Links
 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

--~--~---------~--~----~------------~-------~--~----~



Problem while creating a new file

by roland » Mon, 29 Dec 2008 22:16:36 GMT


 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();
        }
}




--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Problem while creating a new file

by sarwees » Tue, 30 Dec 2008 03:13:13 GMT


 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()).




--~--~---------~--~----~------------~-------~--~----~



Problem while creating a new file

by Ashok Kumar » Tue, 30 Dec 2008 14:41:49 GMT


 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







--~--~---------~--~----~------------~-------~--~----~



Problem while creating a new file

by Ashok Kumar » Tue, 30 Dec 2008 17:50:22 GMT


 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: ");
}









--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. attributes for multiple resources in attrs.xml

Just don't re-declare the format in the second one.  Also, if this is a
color, don't you want the format to be "color"?  As it is now, when you
write a color of the form "0xfff" you will not get the right integer value
for an aarrggbb color.

Oh and I am almost positive the framework already has a color attribute
defines, so you could just use that.






-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~---------~--~----~------------~-------~--~----~

2. opencore RTSP streaming NAT/firewall issue

Hi,

I have encountered such a streaming issue in China.

Per G1 phone's test, if we connect it at site A by EGPRS, it work fine
for RTSP streaming. but  when we change it to site B in the same city,
it will not work. Playback can contine but no any audio/video can be
hear/display.

According to the ethereal log, UDP packet has can be sent out from
handset but no any UDP pacet can be received from server. I think it
should be a NAT poke packet issue.


========================================================
OPTIONS
rtsp://wwan.rtsp-youtube.l.google.com/CkYLENy73wIaPQlvsvVug2kxVxMYDSANFEIJbXYtZ29vZ2xlSARSBWluZGV4Wg5DbGlja1RodW1ibmFpbGC35oDJ0qrPo30M/0/0/0/video.3gpRTSP/1.0
CSeq: 0
User-Agent: PVCore/05.02.00.00 PVPlayer/6.18 (Linux; Android; NJ)
ClientChallenge: 9e26d33f2984236010ef6253fb1887f7
PlayerStarttime: [28/03/2003:22:50:23 00:00]
CompanyID: KnKV4M4I/B2FjJ1TToLycw==
GUID: 00000000-0000-0000-0000-000000000000

DESCRIBE
rtsp://wwan.rtsp-youtube.l.google.com/CkYLENy73wIaPQlvsvVug2kxVxMYDSANFEIJbXYtZ29vZ2xlSARSBWluZGV4Wg5DbGlja1RodW1ibmFpbGC35oDJ0qrPo30M/0/0/0/video.3gpRTSP/1.0
CSeq: 1
User-Agent: PVCore/05.02.00.00 PVPlayer/6.18 (Linux; Android; NJ)
Accept: application/sdp
Accept-Encoding:

RTSP/1.0 200 OK
Public: DESCRIBE, GET_PARAMETER, OPTIONS, PAUSE, PLAY, SETUP,
SET_PARAMETER, TEARDOWN
CSeq: 0
Server: Google RTSP 1.0

RTSP/1.0 200 OK
Content-Type: application/sdp
Cache-Control: must-revalidate
Date: Wed, 11 Mar 2009 06:10:20 GMT
Expires: Wed, 11 Mar 2009 06:10:20 GMT
Last-Modified: Wed, 11 Mar 2009 06:10:20 GMT
Content-Base:
rtsp://wwan.rtsp-youtube.l.google.com/CkILENy73wIaOQlvsvVug2kxVxMYDSANFEIJbXYtZ29vZ2xlSARSBWluZGV4Wg5DbGlja1RodW1ibmFpbGC35oDJAgw=/0/0/0/video.3gp/
CSeq: 1
Server: Google RTSP 1.0
Content-Length: 406

v=0
o=GoogleStreamer 727278696 1107581098 IN IP4 209.85.229.177
s=Video
c=IN IP4 0.0.0.0
b=AS:61
t=0 0
a=control:*
a=range:npt=0-555.133000
m=video 0 RTP/AVP 98
b=AS:49
a=rtpmap:98 H263-2000/90000
a=control:trackID=0
a=cliprect:0,0,144,176
a=framesize:98 176-144
a=fmtp:98 profile=0;level=10
m=audio 0 RTP/AVP 99
b=AS:12
a=rtpmap:99 AMR/8000/1
a=control:trackID=1
a=fmtp:99 octet-align
SETUP
rtsp://wwan.rtsp-youtube.l.google.com/CkILENy73wIaOQlvsvVug2kxVxMYDSANFEIJbXYtZ29vZ2xlSARSBWluZGV4Wg5DbGlja1RodW1ibmFpbGC35oDJAgw=/0/0/0/video.3gp/trackID=0RTSP/1.0
CSeq: 2
User-Agent: PVCore/05.02.00.00 PVPlayer/6.18 (Linux; Android; NJ)
Transport: RTP/AVP/UDP;unicast;client_port=16344-16345
Blocksize: 1400

RTSP/1.0 200 OK
Session: 47ba03fd;timeout=90
Transport: RTP/
AVP;unicast;mode=play;client_port=36064-36065;server_port=10580-10581;source=209.85.229.177;ssrc=59EAD27E
Cache-Control: must-revalidate
Date: Wed, 11 Mar 2009 06:10:22 GMT
Expires: Wed, 11 Mar 2009 06:10:22 GMT
Last-Modified: Wed, 11 Mar 2009 06:10:22 GMT
CSeq: 2
Server: Google RTSP 1.0

SETUP
rtsp://wwan.rtsp-youtube.l.google.com/CkILENy73wIaOQlvsvVug2kxVxMYDSANFEIJbXYtZ29vZ2xlSARSBWluZGV4Wg5DbGlja1RodW1ibmFpbGC35oDJAgw=/0/0/0/video.3gp/trackID=1RTSP/1.0
CSeq: 3
Session: 47ba03fd
User-Agent: PVCore/05.02.00.00 PVPlayer/6.18 (Linux; Android; NJ)
Transport: RTP/AVP/UDP;unicast;client_port=16346-16347
Blocksize: 1400

RTSP/1.0 200 OK
Session: 47ba03fd;timeout=90
Transport: RTP/
AVP;unicast;mode=play;client_port=36066-36067;server_port=10580-10581;source=209.85.229.177;ssrc=47A1BDF6
Cache-Control: must-revalidate
Date: Wed, 11 Mar 2009 06:10:23 GMT
Expires: Wed, 11 Mar 2009 06:10:23 GMT
Last-Modified: Wed, 11 Mar 2009 06:10:23 GMT
CSeq: 3
Server: Google RTSP 1.0

PLAY
rtsp://wwan.rtsp-youtube.l.google.com/CkILENy73wIaOQlvsvVug2kxVxMYDSANFEIJbXYtZ29vZ2xlSARSBWluZGV4Wg5DbGlja1RodW1ibmFpbGC35oDJAgw=/0/0/0/video.3gpRTSP/1.0
CSeq: 4
Session: 47ba03fd
User-Agent: PVCore/05.02.00.00 PVPlayer/6.18 (Linux; Android; NJ)
Range: npt=0.000-555.133

RTSP/1.0 200 OK
Session: 47ba03fd;timeout=90
Range: npt=0.000-555.133
RTP-Info: url=rtsp://wwan.rtsp-youtube.l.google.com/
CkILENy73wIaOQlvsvVug2kxVxMYDSANFEIJbXYtZ29vZ2xlSARSBWluZGV4Wg5DbGlja1RodW1ibmFpbGC35oDJAgw=/
0/0/0/video.3gp/trackID=0;seq=65476;rtptime=495184243,url=rtsp://
wwan.rtsp-youtube.l.google.com/
CkILENy73wIaOQlvsvVug2kxVxMYDSANFEIJbXYtZ29vZ2xlSARSBWluZGV4Wg5DbGlja1RodW1ibmFpbGC35oDJAgw=/
0/0/0/video.3gp/trackID=1;seq=55383;rtptime=1062456782
CSeq: 4
Server: Google RTSP 1.0

TEARDOWN
rtsp://wwan.rtsp-youtube.l.google.com/CkILENy73wIaOQlvsvVug2kxVxMYDSANFEIJbXYtZ29vZ2xlSARSBWluZGV4Wg5DbGlja1RodW1ibmFpbGC35oDJAgw=/0/0/0/video.3gpRTSP/1.0
CSeq: 5
Session: 47ba03fd
Connection: close
========================================================


Maybe any m.youtube.com link has such a issue. below link just for
reference:
 
rtsp://wwan.rtsp-youtube.l.google.com/CkYLENy73wIaPQlvsvVug2kxVxMYDSANFEIJbXYtZ29vZ2xlSARSBWluZGV4Wg5DbGlja1RodW1ibmFpbGC35oDJ0qrPo30M/0/0/0/video.3gp

After turn off the firewall packet, the link can work fine. but at
some other place, we really need turn on the firewall packet. So I
think it's really necessary for opencore to add a dynamical mechanism
to decide send such a packet or not.

BRs
tiger
--~--~---------~--~----~------------~-------~--~----~

3. SDK1.5: adb with one real device via ethernet and one emulated device

4. How to send SMS between two emulators (SDK 1.5 or older)

5. Direct Video Encoder Access?

6. starting two emulators and building apps for one or the other with new 1.5 SDK

7. How can I test the video recording functionality in the new emulator