Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. private void deleteMedia(final String advName) {
  2. File path = Environment.getExternalStorageDirectory();
  3. File directory = new File(path.getAbsolutePath() + "/your directory name");
  4. if (!directory.exists()) {
  5. directory.mkdir();
  6. }
  7. File[] files = directory.listFiles(new FilenameFilter() {
  8. @Override
  9. public boolean accept(File dir, String name) {
  10. return name.contains(advName);
  11. }
  12. });
  13. if (files != null) {
  14. for (int i = 0; i < files.length; i++) {
  15. File file = files[i];
  16. file.delete();
  17. }
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement