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",
Context.MODE_PRIVATE);
cachedImage.compress(CompressFormat.JPEG, 75, Os);
Os.close();


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);
Is.close();


**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)
 http://commonsware.com  |  http://github.com/commonsguy 
 http://commonsware.com/blog  |  http://twitter.com/commonsguy 

Android Training...At Your Office:  http://commonsware.com/training 

--


Sponsored Links


Other Threads

1. Google Login Service not working on SDK 1.5

I downloaded the latest release of android SDK 1.5, but unable to give
the credentials for the "Google Login Service" from devTools. Clicking
on the Google button or any other button crashes. I need to specify
the google credentials to access the calendar application so that I
can customize it as per the requirements. Can you please let me know
if there is any other work around of doing this and accessing the
calendar application?

Thanks
Farida

--~--~---------~--~----~------------~-------~--~----~

2. Convert PDF to XML

Convert to XML specialize in converting your PDF document into xml and
vice versa. We convert your PDF file into XML format at reasonable
rates with quality and accuracy. Use our FREE trial to check whether
our PDF to XML conversion services meets your needs.

Outsource all your PDF conversion requirements to us and save cost up
to 60%. We offer fast, reliable, efficient and accurate PDF to XML
conversion services at lesser costs. To, know more information about
our convert to PDF services visit us.

Convert to XML specialize in converting your data into xml format such
as convert HTML to XML, convert PDF to XML, convert Word to XML.
Convert your data, text, file, database and document into XML at
reasonable rates.

Get ideal solutions for your business needs by our conversion
specialists. Get a FREE quote for your projects.

For more information please visit us at: http://www.converttoxml.com/
or just drop your requirements at: i...@converttoxml.com



--~--~---------~--~----~------------~-------~--~----~

3. Bitmap from Camera Preview using BitmapFactory.decodeByteArray

4. How can I store a file in content provider?

5. IHardwareService. How to use in your code?

6. Question about setComponent() of Iintent

7. Why the duration of clip is differen between VideoView.getDuration and MediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADAT A_KEY_DURATION)