/** * Delete the wishlist * * @param mCtx A context to open the file wish */ public static void ResetCards(Context mCtx) { String[] files = mCtx.fileList(); for (String fileName : files) { if (fileName.equals(WISHLIST_NAME)) { mCtx.deleteFile(fileName); } } }
public static boolean fileExists(Context ctx, String filename) { synchronized (SafeSlinger.sDataLock) { String[] files = ctx.fileList(); if (files != null) { for (String file : files) { if (file.equalsIgnoreCase(filename)) { return true; } } } } return false; }
@Before public void setUp() throws Exception { ShadowLog.stream = System.out; transcript = new Transcript(); context = new Activity(); ObsDetails obsDetails = ObsDetails.getInstance(); obsDetails.setCompanyCode("coco"); obsDetails.setUsername("david"); final String[] fList = context.fileList(); boolean configExists = false; f = new File( HttpMessageConverterTest.class.getClassLoader().getResource(TOKEN_FILE_NAME).toURI()); Assert.assertTrue(f.exists()); for (String fname : fList) { configExists = configExists || TOKEN_FILE_NAME.equals(fname); } try { f = new File( HttpMessageConverterTest.class.getClassLoader().getResource(TOKEN_FILE_NAME).toURI()); Assert.assertTrue(f.exists()); tokenConfiguration = (new TokenConfiguration()).load(f, "lucky13".toCharArray()); if (tokenConfiguration.getDomains().size() == 0) { TokenConfiguration.save(tokenConfiguration, f, "lucky13".toCharArray()); setupFacade.init(); } else { Logger.debug("Unable to create token Configuration"); } } catch (Exception e) { Logger.debug("HomeMenu" + "Exception thrown: " + e.getMessage()); } Robolectric.getBackgroundScheduler().pause(); Robolectric.getUiThreadScheduler().pause(); }
/** * Returns the set of all existent log file names in descending order by name. Returns an empty * set if there aren't any files */ private SortedSet<String> getLogFileNames(String lowerFile, boolean include) { // Get the list of files List<String> list = Arrays.asList(mContext.fileList()); // Reverses the order and stores into a sorted set SortedSet<String> result = new TreeSet<String>(Collections.reverseOrder()); if (list != null) { result.addAll(list); } // Retrieves the subset after the given file name including or excluding given name if (lowerFile != null) { result = result.tailSet(lowerFile); if (!include) { result.remove(lowerFile); } } return result; }