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. How to create a slider on Android with JavaScript, Touchmove

My previous thread on this topic seems to have died out, so I'm going
to change my approach and question.

Is there any way, at all, on this planet or any other, to get a
Javascript slider to work on Android?

The key seems to be that the "thumb" of the slider needs to be
accessible by a "touchmove" event.

If anyone can provide a working example, or a tutorial, or a  or any
kind of indication one way or another of how this is done, I would be
greatly appreciative.

Thank you for any advice.

2. inaccessible resources in android.jar


Does anyone have an idea if (how?) some of the resources (e.g.
drawables) present in android.jar, but inaccessible through
android.R.* can be accessed?

If you want to use the system-wide horizontal separator drawable, the
<divider_horizontal_bright.9.png> resource accessible through the
<android.R.divider_horizontal_bright> ID works fine.

However, when I needed the system-wide VERTICAL separator drawable, I
got stuck. Although the file <divider_vertical_bright.9.png> exists in
the same directory as <divider_horizontal_bright.9.png>, there is no
corresponding <android.R.divider_vertical_bright> ID defined that I
could use.

I ended up taking the resource out from the JAR and adding it to my
project's resources, but I dont like this..

Thank you for any suggestions,



3. ListActivity and an alternative view for error message?

4. ListActivity and an alternative view for error message?

5. Scaling OverlayItems with zoom level

6. Bounds of a LayerDrawable?

7. Android 1.6 startPreview failed with SURFACE_TYPE_NORMAL