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 square root function

Could someone post an example of the square root function? As an
example, there is a double called val. I want to do something like
sqrt(val).

Thanks.

-- 

2. Invoke GlobalActions dialog (Shutdown/Reboot...) on Android-x86

I am not a framework guy...so can't think about any hack on framework
for this purpose.

But in driver level, I can produce the same.

You can make a driver registered as Input device and set the keybit on
KEY_END. When you want to shutdown, give a call to driver which will
in turn report key press event on that.

Android eventhub will automatically listen to this event and framework
will create power off menu on this.

regards,
Tirtha



On Apr 23, 5:34pm, Christian Erpelding


> reading

3. Simulate the SIM in the emulator how to do that?

4. How many Android phones have touchscreens?

5. Paket Baru WTI: Internet Unlimited XL naik menjadi Rp 250 ribu/bulan

6. How many Android phones have touchscreens?

7. Reading Notifications