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. Can't understand how to query ContentProvider - java.lang.IllegalArgumentException: Unknown URL

Figured it out.
Making the url all lower-case letters made the error go away  ( even
though table name had capital letters in it ).





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

2. install apk

Hi, how can I install .apk file by using java code. that is , we can
install .apk from cmd
"adb install program_name.apk" I wonder that how can we install .apk
file bu using another program. To summarize I will have button and
when user click it another program(in sdcard) will be installed to
phone. Thanks for reply.
--~--~---------~--~----~------------~-------~--~----~

3. Can't understand how to query ContentProvider - java.lang.IllegalArgumentException: Unknown URL

4. Struggling -- Getting exception when clicked on HelloItemizedOverlay

5. Unable to debug on HTC MyTouch

6. How do you get all table names exposed by a given Content Provider?

7. WHY is there a NULL POINTER EXCEPTION? Been confusing me for a while.