當前位置: 首頁>>代碼示例>>Java>>正文


Java Context.deleteFile方法代碼示例

本文整理匯總了Java中android.content.Context.deleteFile方法的典型用法代碼示例。如果您正苦於以下問題:Java Context.deleteFile方法的具體用法?Java Context.deleteFile怎麽用?Java Context.deleteFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.Context的用法示例。


在下文中一共展示了Context.deleteFile方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: deleteStackTrace

import android.content.Context; //導入方法依賴的package包/類
/**
 * Deletes the give filename and all corresponding files (same name,
 * different extension).
 */
private static void deleteStackTrace(WeakReference<Context> weakContext, String filename) {
    Context context = null;
    if (weakContext != null) {
        context = weakContext.get();
        if (context != null) {
            context.deleteFile(filename);

            String user = filename.replace(".anr", ".user");
            context.deleteFile(user);

            String contact = filename.replace(".anr", ".contact");
            context.deleteFile(contact);

            String description = filename.replace(".anr", ".description");
            context.deleteFile(description);
        }
    }
}
 
開發者ID:pre-dem,項目名稱:pre-dem-android,代碼行數:23,代碼來源:TraceInfoCatcher.java

示例2: deleteStackTrace

import android.content.Context; //導入方法依賴的package包/類
/**
 * Deletes the give filename and all corresponding files (same name,
 * different extension).
 */
private static void deleteStackTrace(WeakReference<Context> weakContext, String filename) {
    Context context = null;
    if (weakContext != null) {
        context = weakContext.get();
        if (context != null) {
            context.deleteFile(filename);

            String user = filename.replace(".stacktrace", ".user");
            context.deleteFile(user);

            String contact = filename.replace(".stacktrace", ".contact");
            context.deleteFile(contact);

            String description = filename.replace(".stacktrace", ".description");
            context.deleteFile(description);

            SharedPreUtil.removeCrashConfirmedFilenames(context);
        }
    }
}
 
開發者ID:pre-dem,項目名稱:pre-dem-android,代碼行數:25,代碼來源:CrashManager.java

示例3: DeleteOrphansNotInList

import android.content.Context; //導入方法依賴的package包/類
public static void DeleteOrphansNotInList(PictureDestination pd, ArrayList<String> alImages, Context c) {
    MFBImageInfo mfbii = new MFBImageInfo(pd);
    String szPrefix = mfbii.getImagePrefix();
    String szSuffix = mfbii.getImageSuffix();

    Log.w(MFBConstants.LOG_TAG, String.format("Delete orphans for %s", pd.toString()));
    // Get a list of all the files
    String[] rgszFiles = c.fileList();

    // Now delete any images that match the prefix but which aren't in our list.
    for (String szFile : rgszFiles)
        if (szFile.startsWith(szPrefix) && szFile.endsWith(szSuffix) && !alImages.contains(szFile)) {
            Log.e(MFBConstants.LOG_TAG, "ORPHAN FOUND TO DELETE: " + szFile);
            c.deleteFile(szFile);
        }
}
 
開發者ID:ericberman,項目名稱:MyFlightbookAndroid,代碼行數:17,代碼來源:MFBImageInfo.java

示例4: SqlLiteHelper

import android.content.Context; //導入方法依賴的package包/類
/**
 * Constructor used to create database if database does not already exist.
 * Will delete existing Hexis database if PURGE_DATABASE is true
 *
 * @param context   Program context
 */
public SqlLiteHelper(Context context) {
  super(context, DATABASE_NAME, null, DATABASE_VERSION);
  // Delete Hexis database if PURGE_DATABASE is true
  if (PURGE_DATABASE) {

    // For testing purposes we need to delete the database so onCreate will be called
    context.deleteDatabase(DATABASE_NAME);

    // Delete actual database file from filesystem
    context.deleteFile(DATABASE_NAME);
  }
}
 
開發者ID:Austin-Ray,項目名稱:Hexis,代碼行數:19,代碼來源:SqlLiteHelper.java

示例5: removeProfile

import android.content.Context; //導入方法依賴的package包/類
public void removeProfile(Context context, VpnProfile profile) {
    String vpnentry = profile.getUUID().toString();
    profiles.remove(vpnentry);
    saveProfileList(context);
    context.deleteFile(vpnentry + ".vp");
    if (mLastConnectedVpn == profile) mLastConnectedVpn = null;
}
 
開發者ID:akashdeepsingh9988,項目名稱:Cybernet-VPN,代碼行數:8,代碼來源:ProfileManager.java

示例6: deleteAllApiFileCache

import android.content.Context; //導入方法依賴的package包/類
public static void deleteAllApiFileCache(Context context) {
    if (context != null) {
        String[] fileNames = context.fileList();
        if (!BaseTypeUtils.isArrayEmpty(fileNames)) {
            synchronized (fileNames) {
                for (String cacheName : fileNames) {
                    context.deleteFile(cacheName);
                }
            }
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:13,代碼來源:FileUtils.java

示例7: deleteBitmap

import android.content.Context; //導入方法依賴的package包/類
public static void deleteBitmap(Context context, ComponentName cname, IconType iconType) {

        String fname  = makeSafeName(cname, iconType);
        if (fileExists(context, fname)) {
            context.deleteFile(fname);
        }

    }
 
開發者ID:quaap,項目名稱:LaunchTime,代碼行數:9,代碼來源:SpecialIconStore.java

示例8: delete

import android.content.Context; //導入方法依賴的package包/類
@Override
public void delete(Context context) {
    if (mImageFile != null) {
        context.deleteFile(mImageFile.getName());
    }
    mImageFile = null;
}
 
開發者ID:mvescovo,項目名稱:item-reaper,代碼行數:8,代碼來源:ImageFileImpl.java

示例9: deleteApiFileCache

import android.content.Context; //導入方法依賴的package包/類
public static void deleteApiFileCache(Context context, String cacheName) {
    if (context != null && !TextUtils.isEmpty(cacheName)) {
        context.deleteFile(cacheName);
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:6,代碼來源:FileUtils.java

示例10: reset

import android.content.Context; //導入方法依賴的package包/類
public static void reset(Context context, String name) {
    context.deleteFile(PREFIX + name);
}
 
開發者ID:feifadaima,項目名稱:https-github.com-hyb1996-NoRootScriptDroid,代碼行數:4,代碼來源:DrawableSaver.java

示例11: clearObject

import android.content.Context; //導入方法依賴的package包/類
public static void clearObject(String filename, Context context) {
    try {
        context.deleteFile(filename);
    } catch (Exception ignored) { }
}
 
開發者ID:dmllr,項目名稱:IdealMedia,代碼行數:6,代碼來源:FileUtils.java

示例12: resetValues

import android.content.Context; //導入方法依賴的package包/類
public static void resetValues(Context context, String[] filenames) {
    for(String filename : filenames) {
        context.deleteFile(filename);
    }
}
 
開發者ID:pradeep1991singh,項目名稱:react-native-secure-key-store,代碼行數:6,代碼來源:Storage.java

示例13: handleWordList

import android.content.Context; //導入方法依賴的package包/類
/**
 * Handle a word list: put it in its right place, and update the passed content values.
 * @param context the context for opening files.
 * @param inputStream an input stream pointing to the downloaded data. May not be null.
 *  Will be closed upon finishing.
 * @param downloadRecord the content values to fill the file name in.
 * @throws IOException if files can't be read or written.
 * @throws BadFormatException if the md5 checksum doesn't match the metadata.
 */
private static void handleWordList(final Context context,
        final InputStream inputStream, final DownloadRecord downloadRecord)
        throws IOException, BadFormatException {

    // DownloadManager does not have the ability to put the file directly where we want
    // it, so we had it download to a temporary place. Now we move it. It will be deleted
    // automatically by DownloadManager.
    DebugLogUtils.l("Downloaded a new word list :", downloadRecord.mAttributes.getAsString(
            MetadataDbHelper.DESCRIPTION_COLUMN), "for", downloadRecord.mClientId);
    PrivateLog.log("Downloaded a new word list with description : "
            + downloadRecord.mAttributes.getAsString(MetadataDbHelper.DESCRIPTION_COLUMN)
            + " for " + downloadRecord.mClientId);

    final String locale =
            downloadRecord.mAttributes.getAsString(MetadataDbHelper.LOCALE_COLUMN);
    final String destinationFile = getTempFileName(context, locale);
    downloadRecord.mAttributes.put(MetadataDbHelper.LOCAL_FILENAME_COLUMN, destinationFile);

    FileOutputStream outputStream = null;
    try {
        outputStream = context.openFileOutput(destinationFile, Context.MODE_PRIVATE);
        copyFile(inputStream, outputStream);
    } finally {
        inputStream.close();
        if (outputStream != null) {
            outputStream.close();
        }
    }

    // TODO: Consolidate this MD5 calculation with file copying above.
    // We need to reopen the file because the inputstream bytes have been consumed, and there
    // is nothing in InputStream to reopen or rewind the stream
    FileInputStream copiedFile = null;
    final String md5sum;
    try {
        copiedFile = context.openFileInput(destinationFile);
        md5sum = MD5Calculator.checksum(copiedFile);
    } finally {
        if (copiedFile != null) {
            copiedFile.close();
        }
    }
    if (TextUtils.isEmpty(md5sum)) {
        return; // We can't compute the checksum anyway, so return and hope for the best
    }
    if (!md5sum.equals(downloadRecord.mAttributes.getAsString(
            MetadataDbHelper.CHECKSUM_COLUMN))) {
        context.deleteFile(destinationFile);
        throw new BadFormatException("MD5 checksum check failed : \"" + md5sum + "\" <> \""
                + downloadRecord.mAttributes.getAsString(MetadataDbHelper.CHECKSUM_COLUMN)
                + "\"");
    }
}
 
開發者ID:sergeychilingaryan,項目名稱:AOSP-Kayboard-7.1.2,代碼行數:63,代碼來源:UpdateHandler.java


注:本文中的android.content.Context.deleteFile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。