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. Android 1.5 SDK, Release 2

Android 1.5 SDK Release 2 is now available for download from the Android
Developer web site <http://developer.android.com/sdk/1.5_r2/index.html>.
This update includes the security patch as mentioned at
oCERT<http://www.ocert.org/advisories/ocert-2009-006.html>
.

Xav
-- 
Xavier Ducrohet
Android Developer Tools Engineer
Google Inc.

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

2. Anyone else got a post-Cupcake upgrade on their UK G1

Great. "Test it on that little island near the dangerous countries
first, make sure it's safe to roll out!"

Anyone know why we still don't have voice search? Not that I'm
particularly bothered, just makes me wonder what other features we're
missing in the UK variant...






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

3. RPC Best Practices

4. Trying to create a Android Client that can call a .NET Web Service

5. Android 1.5 modifying width & Height

6. Split XML files or use db?

7. How to create an array of edit text controls in a tableview?