标签:
final File directory = new File( "/sdcard/Android/data/com.baway.test/cache/xBitmapCache"); clear.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (directory != null && directory.exists() && directory.isDirectory()) { for (File item : directory.listFiles()) { item.delete(); } Toast.makeText(MainActivity.this, "yiqinghcu", 0).show(); } } });
判断网络连接的方法
// 判断网络连接状态的方法 ConnectivityManager conn = (ConnectivityManager) MainActivity.this .getSystemService(Context.CONNECTIVITY_SERVICE); if (conn != null) { NetworkInfo info = conn.getActiveNetworkInfo(); if (info != null && info.isConnected()) { if (info.getState() == NetworkInfo.State.CONNECTED) { Toast.makeText(MainActivity.this, "网络连接正常", 0).show(); } } }
需要添加的权限
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
标签:
原文地址:http://www.cnblogs.com/daidai123/p/5551728.html