fix cleanPrivateStorage() (#3065)
This commit is contained in:
		
							parent
							
								
									258c7d1b3b
								
							
						
					
					
						commit
						d86f0787da
					
				| 
						 | 
					@ -278,34 +278,15 @@ public class SettingsActivity extends XmppActivity implements
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private boolean cleanPrivateStorage() {
 | 
						private boolean cleanPrivateStorage() {
 | 
				
			||||||
		cleanPrivatePictures();
 | 
							for(String type : Arrays.asList("Images", "Videos", "Files", "Recordings")) {
 | 
				
			||||||
		cleanPrivateFiles();
 | 
							        cleanPrivateFiles(type);
 | 
				
			||||||
 | 
						    }
 | 
				
			||||||
		return true;
 | 
							return true;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private void cleanPrivatePictures() {
 | 
						private void cleanPrivateFiles(final String type) {
 | 
				
			||||||
		try {
 | 
							try {
 | 
				
			||||||
			File dir = new File(getFilesDir().getAbsolutePath(), "/Pictures/");
 | 
								File dir = new File(getFilesDir().getAbsolutePath(), "/" + type + "/");
 | 
				
			||||||
			File[] array = dir.listFiles();
 | 
					 | 
				
			||||||
			if (array != null) {
 | 
					 | 
				
			||||||
				for (int b = 0; b < array.length; b++) {
 | 
					 | 
				
			||||||
					String name = array[b].getName().toLowerCase();
 | 
					 | 
				
			||||||
					if (name.equals(".nomedia")) {
 | 
					 | 
				
			||||||
						continue;
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
					if (array[b].isFile()) {
 | 
					 | 
				
			||||||
						array[b].delete();
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		} catch (Throwable e) {
 | 
					 | 
				
			||||||
			Log.e("CleanCache", e.toString());
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	private void cleanPrivateFiles() {
 | 
					 | 
				
			||||||
		try {
 | 
					 | 
				
			||||||
			File dir = new File(getFilesDir().getAbsolutePath(), "/Files/");
 | 
					 | 
				
			||||||
			File[] array = dir.listFiles();
 | 
								File[] array = dir.listFiles();
 | 
				
			||||||
			if (array != null) {
 | 
								if (array != null) {
 | 
				
			||||||
				for (int b = 0; b < array.length; b++) {
 | 
									for (int b = 0; b < array.length; b++) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue