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",
cachedImage.compress(CompressFormat.JPEG, 75, Os);

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);

**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)  |  | 

Android Training...At Your Office: 


Sponsored Links

Other Threads

1. Using Corporate Based Web Proxy via Wifi

I've tried searching everywhere for this problem and all I get back in
result is tethering information.  I have setup a shortcut with AnyCut
to set the proxy settings for my device, but connecting via wifi I
still cannot get out through my corporate-based proxy?  Anyone have
any success with this shortcut?  Is it really setting the proxy or am
I just being fooled by the interface.  Are there any other network
tools I can try?

Also, I am able to browse through the corporate LAN without the proxy
setting to local websites... when I put in the proxy settings, it
breaks everything.

Thanks... Chris


2. ConnectivityManager with the emulator


I want to implement with the emulator an application that receives
information when the network connection is connected or disconnected.
How can I register a receiver that gets the changes in the network

I have tried this:

        public class ConnectionChangeReceiver extends BroadcastReceiver {

                public void onReceive(Context context, Intent intent) {
                        ConnectivityManager connectivityManager =
                        NetworkInfo activeNetInfo = 
                        NetworkInfo mobNetInfo = 

                                IntentFilter intentFilter = new IntentFilter();
ConnectionChangeReceiver(), intentFilter);

What should be the input of the filter so that the ConnectivityManager
sends information to my receiver?

And one more question.

I have done some tests with the emulator with the following code:

ConnectivityManager connManager = (ConnectivityManager)
NetworkInfo activeNetworkInfo = connManager.getActiveNetworkInfo();

I get the information that the MOBILE network type is available and
its state is CONNECTED. If I disable the local area connection on my
PC I get the same information. How can make the network information
change? How can I disable/enable the connection for simulations?

Thank you in advance.

Best wishes!

3. Help to port android on openmoko

4. Android on neo1973

5. How to configure android emulator disk space?

6. Creating a TabHost with Tabs containing Activities WITHOUT extending TabActivity

7. packagemanagerservice signature verificatio