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. Guide Me Right Way

hi,i m very new on mobile application development. i want to learn
Android. but i dont know where to start actually. i tried defferent
web including developer.android and i deffernt books as well. But
problem is i dnt know java at all. And all most everywere i found they
write some code and then traslate it in android code to explane. but
person like me who have no idea about any of it is very tough. So that
is best proctice- first learn java then Android or learn android with
part of java (onbly required to understand android). sorry for bad
english.

-- 

2. Google vs Flurry

I want to start tracking usage of my apps. I need to decide on who to
use Google Mobile Analytics or Flurry. Does anyone have an opinion?

-- 

3. Novatel Wireless Modem

4. Using Gmail content provider

5. JDK dynamic proxy : it works on Android :-)

6. Record raw Audio, process audio and save as ogg or another compressed format

7. OOT: Paging Medan Androidan..