package com.tware.pdfdrop; import java.io.File; import android.app.Activity; import android.graphics.Color; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.TextView; public class PdfDropActivity extends Activity{ /** Called when the activity is first created. */ TextView textview; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); textview = (TextView)findViewById(R.id.v_file_list); View clsbtn = findViewById(R.id.btn_clean); clsbtn.setOnClickListener(new OnClickListener(){ public void onClick(View v) { File f = new File("/sdcard"); File[] fl = f.listFiles(); for (int i=0; i<fl.length; i++) { if(fl[i].toString().endsWith(".pdf") || fl[i].toString().endsWith(".PDF")) { if(fl[i].delete()) { textview.setTextSize(20); textview.setTextColor(Color.GREEN); textview.append(" " + fl[i].toString()+ "--- Success"); }else{ textview.setTextSize(20); textview.setTextColor(Color.RED); textview.append(" " + fl[i].toString()+ "--- Failed"); } } } } }); } }