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. Job opening at RNT Labs Chandigarh

Hi ,

Urgent job opening for IPhone ,Android, RIM developers

Please apply at " " with your expected CTC and resume .

For more details feel free to contact me .


Piyush Gupta


2. /to Gold

You can stat a new activity by using intent i=intent(current class,new
i.startactivity(current class); //check spelling


3. Remove mobile metatag

4. Efficient way of using TranslateAnimation to move something across the screen over and over

5. Browser Crash in Froyo

6. best approach about database

7. Problem with ACTION_SEARCH Intent on Nexus since update to 2.2 ?