Open top menu




Explain- The Log file delete alternate in  3 days.


import android.content.Context;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Date;


public class LogFile {

    Context context;

     public LogFile ( ) {

        DeletOlderFolder();
    }

    public void DeletOlderFolder(){

        File file=new File("sdcard/LoungeLogFile.txt");

        if(file != null) {

            long diff = new Date().getTime() - file.lastModified();

            if (diff > 3 * 24 * 60 * 60 * 1000) {

                file.delete();

            }

        }

    }

}
 
 

public class MainActivity extends Activity  {
 
@Override

protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
 
 
new LogFile (); // Delete Log file in 3 days
 
 
}
}


Tagged

0 comments