private void scanFile(File file) { String path = file.getAbsolutePath(); if (TypeFilter.isMusicFile(path)) { /* * notify the media to scan */ Uri mUri = Uri.fromFile(file); Intent mIntent = new Intent(); mIntent.setData(mUri); mIntent.setAction(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); context.sendBroadcast(mIntent); } }
@Override public boolean accept(File pathname) { // TODO Auto-generated method stub // keep all needed files try { if (pathname.isDirectory()) { filesNum++; return true; } } catch (SecurityException e) { e.printStackTrace(); return false; } String name = pathname.getAbsolutePath(); if (TypeFilter.isMusicFile(name)) { filesNum++; return true; } return false; }