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. Looking for Talented Developers

Tenth Muse Enterprises is in search of developers with experience in
Android and with the ability to expand our ideas to other platforms.
Currently we have 2 projects (Perseus and Proteus) that are in need of
talented software engineers, one a relatively simple but impactful
product that will utilize GPS and will need to have web or server
based data that is submitted by an end user, and relayed to other end
users.  Very simple.

The other project (Proteus) is much more detailed and in depth and the
details cannot be discussed at all here due to US patent laws, however
I promise that this is a highly ambitious idea that will change the
way mobile devices are used forever.

Please understand that anyone looking to participate in either project
must be willing to sign a strict confidentiality agreement before any
information can be shared, or negotiations for contracted work can

If you are interested in being a part of these exciting projects,
please send your resume and examples or links to your past work to

Thank you,

Tavis Leaf
Tenth Muse Enterprises


2. Running java native programs on android

Is there a way I can a native java program on the android phone?


3. Gallery beneath a square ImageButton, how to create?

4. open market via browser link

5. More hidden shells

6. Debug in Dalvik

7. XML Resource Parser