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. ImageView problem

Hi,

I am working on an android project where the local and remote image
files and their thumbnails are to be displayed. The imageview works
perfectly till the thumbnail part. After that it crashes depending
upon the size of the image file. For example, if the size was ~380kb,
it will open once and then crash the next time you click on its
thumbnail. An image of size around ~150 kb opens properly 3 times and
then crashes the 4th time.

It seems like a out of memory error but I have not been able to work
out a solution. I tried to force close the activity before launching a
new one but that didn't help either. Does anyone has any idea as to
how to work around this issue? I have seen similar problem being
posted on the google group (

2. Tanya tether

Sorry pertanyaan bodoh neh..

Tether itu apaan sih? Gimana kerjanya? Bisa ngapain aja.

Thx

Safitry Ozawa






-- 
Sent from my mobile device

-- 
===============
"

3. Check Camera Chip di Evo 4G

4. Help with animation

5. Phones with Large Internal Storage & EXTERNAL_CONTENT_URI

6. How do you manipulate content in an Activity from an external class or another Activity?

7. Visuals of all standard widgets?