private file last modified date

by Dson » Sun, 01 Aug 2010 13:06:35 GMT

Sponsored Links
 Hi Guys,

 I am trying to get the last modified date of an internal file and it
always returns me 0 although I could read the file properly. Can you
please let me know if I am doing anything wrong...

Creating a file...

FileOutputStream Os = activity.openFileOutput("file1.jpg",
cachedImage.compress(CompressFormat.JPEG, 75, Os);

Reading the file...
long mod_time = 0;
File file = new File("file1".jpg");
mod_time = file.lastModified();
FileInputStream Is = activity.openFileInput("file1.jpg");
cachedImage = BitmapFactory.decodeStream(Is);

**mod_time is always zero!!!!**


private file last modified date

by Mark Murphy » Sun, 01 Aug 2010 14:53:33 GMT


That is because you are looking at the wrong file. Use new
File(getFilesDir(), "file1.jpg") to get at the same file that you use
with openFileInput()/openFileOutput().

Mark Murphy (a Commons Guy)  |  | 

Android Training...At Your Office: 


Sponsored Links

Other Threads

1. HTC Hero Contacts ACTION_INSERT intent returns no result

I'm using this intent to let the user create a contact:

intent = new Intent(Intent.ACTION_INSERT,Contacts.People.CONTENT_URI);
this.startActivityForResult(intent, CREATE_CONTACT_REQUEST);

I use the result of this intent to know uri for the new contact they
created. This works on every android device I've tested except for the
Hero, probably because they have their own Contacts app

Here's the code I use to retrieve the result of the action:

    protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
        if (requestCode == CREATE_CONTACT_REQUEST) {
            if (resultCode == RESULT_OK) {
                Uri newContactUri = data.getData();

On every other device when: resultCode == RESULT_OK  it's safe to
assume that data contains the uri for the newly created contact.
However on the Hero they return RESULT_OK, yet data is equal to null!

Does anybody know how I can figure out the URI for the newly created
contact on the Hero?

Also is anyone aware of a place to report bugs to HTC?
I searched around on their developer site
but didn't find anything.

Thanks a bunch.



2. Imo android tested

Mantapp... Ditunggu ripiw & harganya :p
*root & port ke blur cakep keliatannya, dengan layar yg lebih lega*

Hoesin [PiSANG] 
the plaza semanggi lt.2b no.40 & no.77
e: @

-----Original Message-----
From: "Lucky Sebastian" <>
Date: Fri, 13 Nov 2009 03:29:08 
To: Android<>
Subject: [id-android] Imo android tested

sorry kalau email ini jadi 2x, seven error td lagi kirim.
Ternyata kabar imo buat android bukan isepan jempol, inu saya kebagian testing.
Kecil ukurannya model ala storm:-)
Real android, ohd.


Lucky Sebastian

Sent from my HTC pesulap

Google Groups "Indonesian Android Community [id-android]" group.

To post to this group, send email to

To request to subscribe to this group:


3. Can we create folders under /data directory

4. How to enable Fingerpainting (i.e. API demo example) on a surface, but not only with finger touch

5. Does anyone know how to publish an application to the OPhone's Market?

6. DDMS Screenshot and Archos 5 IT

7. Google Voice on Droid counts as Verizon voice calls