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. Send Mock Gps Data to real Device

Hello,

ich want to know if it's possible to send mock gps data to a real
device that runs my application in debug mode via DDMS.

Sending Mock Gps data to the emulator itself works perfect, but I want
to send the mock data to my device, too.


Thanks for your help

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

2. How do I call another activity method?

Hello!

Ok here is my problem.

I have one Activity (Activity1) containing a tabhost. In one of the
tabs I have a listActivity (Activity2)
Activity2 implements ListActivity  I want to call ( Activity2 )
thisMethodIWantToCall() from Activity1.

Activity1

Intent myHomeIntent = new Intent(this, Activity2.class);

mTabHost.addTab(mTabHost.newTabSpec("tab_test1").setIndicator("",
getResources().getDrawable(R.drawable.myhome)).setContent
(myHomeIntent));

Activity2
public class Home extends ListActivity{

private variables ...

         public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.homescreen);

         some code ...   //

public void thisMethodIWantToCall()
{
   updateMyListAcitivty();
}


If it would be simple I want to think it should work like this...

Intent myHomeIntent = new Intent(this, Activity2.class);

mTabHost.addTab(mTabHost.newTabSpec("tab_test1").setIndicator("",
getResources().getDrawable(R.drawable.myhome)).setContent
(myHomeIntent));

myHomeIntent.updateMyListActivity():

But I know that it dosnt work like that.



Thank you


 Martin Fors

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

3. Inertial Sensor on HTC Hero

4. API responsable to make transfert dwonlaod ,upload with ftp ou 3G protocol

5. Trajectory Calculator

6. EditText`s hint disappeared when "Input Type" is set.

7. does Android support displaying HTML, javascript, etc. within an application?