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

Hello,

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
connection?

I have tried this:

        public class ConnectionChangeReceiver extends BroadcastReceiver {

                @Override
                public void onReceive(Context context, Intent intent) {
                        ConnectivityManager connectivityManager =
(ConnectivityManager)
context.getSystemService(Context.CONNECTIVITY_SERVICE);
                        NetworkInfo activeNetInfo = 
connectivityManager.getActiveNetworkInfo
();
                        NetworkInfo mobNetInfo = 
connectivityManager.getNetworkInfo
(ConnectivityManager.TYPE_MOBILE);
                }
        }

                                IntentFilter intentFilter = new IntentFilter();
                                registerReceiver(new 
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)
getSystemService(Context.CONNECTIVITY_SERVICE);
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