当前位置: 首页>>代码示例>>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;未经允许,请勿转载。