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. Help: Boot failed when enabled Android_Power in 2.6.24 on Marvell Board

Hi, all

I'm porting Android 1.0 (2.6.25 based) to Marvell PXA9xx board with
2.6.24 kernel. Considering the workloads of drivers porting, I degrade
the android to 2.6.24.  At present, Many necessary features (ASHMEM,
BINDER...) and drivers have been ported successfully and Android
homescreen and applications can be displayed. But when I enabled the
ANDROID_POWER( of course, some modification also have been performed
accroding to the kobject/kset difference between 2.6.24 and 2.6.25 to
register subsystem 'android_power' in /sys),  the system stopped at
kernel compression done like below:
------------------------------------------------------------------------------------
Uncompressing
Linux.............................................................
................................................................................
................ done, booting the kernel.
-------------------------------------------------------------------------------------

I have checked the kernel source code carefully and thought that
ANDROID_POWER shouldn't be the reason of system boot failure but it
did. No other choices but turn to help in developer forum.  Doesn't
anybody account with the similar problems? and could anyone help me
out?

Thanks a lot!

BR/Mark
--~--~---------~--~----~------------~-------~--~----~
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: 

2. Roadmap of GPS support in Android

Right now, Android GPS library only supports standalone GPS, Does
anyone know when Android library will support MS-Based AGPS?

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

3. How to have two different fonts within the same ListView item?

4. I really, really, need help with the android emulator sensors, HELP PLEASE!

5. 2008 Top Google Android Skins

6. Perl on Android Emulator

7. How to build Android.jar from the source code