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. want to set the four images horigentally and want to draw the list below images

hi
i want to set the four images like

image1   imag2   image3  image4


when i click on image1  then  i want to display the list of image1
like

image1  image2 image3  image4
A
B
C
D
E
F
G
H
I
J
when i click on image2 then i want to display the list of image2 like

image1  image2   image3   image4
               A
               B
               C
               E
               F
              G
              H
              I
              J














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

2. to set the height of editext in string.xml file

hi sir
i want to set the height of edittext in string.xml file and want to
use in java file.
how can i use it.
plz suggest answer.
thanks in advance.
--~--~---------~--~----~------------~-------~--~----~

3. Android UDP Server

4. catching the KEYCODE_ENDCALL event

5. i want to add another spinner on event of selecting the item in spinner

6. Getting views by type

7. how can i know if im connected