前言
欢迎大家我分享和推荐好用的代码段~~
声明
欢迎转载,但请保留文章原始出处:
CSDN:http://www.csdn.net
雨季o莫忧离:http://blog.csdn.net/luckkof
正文
package com.mediatek.filemanager;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.util.Log;
public class BootCompletedReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals("android.intent.action.BOOT_COMPLETED")) {
SharedPreferences sp = context.getSharedPreferences("filemanager",0);
if (sp.getBoolean("copyFile", true)) {
try {
// copyFile(new File("/storage/sdcard1/ᅫᅧ.mp3"),new
// File("/storage/sdcard1/Ringtones/wen.mp3"));
copyDirectiory("/storage/sdcard1/Ringtones","/storage/sdcard1/Pictures");
Editor editor = sp.edit();
editor.putBoolean("copyFile", false);
editor.commit();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
<receiver android:name="com.mediatek.filemanager.BootCompletedReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />