本文整理匯總了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);
}
}
}
示例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);
}
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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);
}
}
}
}
}
示例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);
}
}
示例8: delete
import android.content.Context; //導入方法依賴的package包/類
@Override
public void delete(Context context) {
if (mImageFile != null) {
context.deleteFile(mImageFile.getName());
}
mImageFile = null;
}
示例9: deleteApiFileCache
import android.content.Context; //導入方法依賴的package包/類
public static void deleteApiFileCache(Context context, String cacheName) {
if (context != null && !TextUtils.isEmpty(cacheName)) {
context.deleteFile(cacheName);
}
}
示例10: reset
import android.content.Context; //導入方法依賴的package包/類
public static void reset(Context context, String name) {
context.deleteFile(PREFIX + name);
}
示例11: clearObject
import android.content.Context; //導入方法依賴的package包/類
public static void clearObject(String filename, Context context) {
try {
context.deleteFile(filename);
} catch (Exception ignored) { }
}
示例12: resetValues
import android.content.Context; //導入方法依賴的package包/類
public static void resetValues(Context context, String[] filenames) {
for(String filename : filenames) {
context.deleteFile(filename);
}
}
示例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)
+ "\"");
}
}