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 on Motorola A810...

Hello ALL,

Can Android be ported on Motorola A810? Has anyone done this?
A little I have come to know that Android was ported on Motorola Ming A1200,
the predecessor of Motorola A810.

Regards,
- sam.

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

2. getting latest version repo

hi

When I run this command , I got this error.
I couldnt find any mistake.

#repo init -u git://android.git.kernel.org/platform/manifest.git


fatal: unable to start 
/mnt/depo/calisma/android-source/mydroid/.repo/repo/main.py
fatal: [Errno 13] Permission denied


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

3. Android make

4. how to use self-signed Certificate Authority

5. How to use print log-data to DDMS in module "external/skia/libsgl/"

6. I'll try port Android to S3C2410

7. "Home Sample" has arrived and I can't make it go away