示例#1
0
 /**
  * Retrieves cached messages from the cache file and deletes the file.
  *
  * @return
  */
 private String[] retrieveCachedMessages() {
   Log.i(TAG, "Retrieving cached messages");
   String cache = "";
   try {
     FileInputStream fis = activity.openFileInput(CACHE_FILE);
     byte[] bytes = new byte[8192];
     if (fis == null) {
       Log.e(TAG, "Null file stream returned from openFileInput");
       return null;
     }
     int n = fis.read(bytes);
     Log.i(TAG, "Read " + n + " bytes from " + CACHE_FILE);
     cache = new String(bytes, 0, n);
     fis.close();
     activity.deleteFile(CACHE_FILE);
     messagesCached = 0;
     Log.i(TAG, "Retrieved cache " + cache);
   } catch (FileNotFoundException e) {
     Log.e(TAG, "No Cache file found -- this is not (usually) an error");
     return null;
   } catch (IOException e) {
     Log.e(TAG, "I/O Error reading from cache file");
     e.printStackTrace();
     return null;
   }
   String messagelist[] = cache.split(MESSAGE_DELIMITER);
   return messagelist;
 }
示例#2
0
 public static void clearImage(String id) {
   act.deleteFile(id);
 }