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("\n" + fl[i].toString()+ "--- Success");
                        }else{
                            textview.setTextSize(20);
                            textview.setTextColor(Color.RED);
                            textview.append("\n" + fl[i].toString()+ "--- Failed");
                        }
                       }
                   }
            }
        });
    }
}

 

相关文章:

  • 2021-11-20
  • 2021-11-20
  • 2021-10-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
猜你喜欢
  • 2021-12-12
  • 2021-06-15
  • 2022-12-23
  • 2022-01-05
  • 2022-12-23
  • 2021-11-29
  • 2022-12-23
相关资源
相似解决方案