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. g1 keyboard missing up/down/left/right keys?

I set up my g1 phone to test the Snake sample came with the Android
SDK. The application requires up/down/left/right keys, but they not
available on the g1 keyboard - did I miss it?

I changed the code to use I, K, J, L keys instead. It works when I
have the device connect to to the computer with Eclipse running. But
the app stops working when I unplugged it from the computer. Is it
because I didn't do a release build? How?

I know, two questions!  Thanks!!!


2. Download Count Reset on App Upgrade in Android Market

I saw the warning when we upgraded our app about the reviews and
ratings being temporarily reset when you do an upgrade.  Can someone
at Android comment on how long it will be before a fix is pushed that
will merge the old comments and ratings with the new ones?

Also, the download count was reset and it was not mentioned in the
warning message.  I assume that too will be merged, is that correct?


3. Invoking the web browser from my app

4. Is there a way to increase the G1's default screen timeout during a call?

5. First Run Method

6. Logistics, bike messenger

7. Userspace Hardware Abstraction layer