parametrize FileImportCache for filename
This commit is contained in:
@@ -477,7 +477,7 @@ public class KeychainIntentService extends IntentService
|
||||
} else {
|
||||
// get entries from cached file
|
||||
FileImportCache<ParcelableKeyRing> cache =
|
||||
new FileImportCache<ParcelableKeyRing>(this);
|
||||
new FileImportCache<ParcelableKeyRing>(this, "key_import.pcl");
|
||||
entries = cache.readCacheIntoList();
|
||||
}
|
||||
|
||||
|
||||
@@ -503,7 +503,8 @@ public class ImportKeysActivity extends ActionBarActivity {
|
||||
// to prevent Java Binder problems on heavy imports
|
||||
// read FileImportCache for more info.
|
||||
try {
|
||||
FileImportCache<ParcelableKeyRing> cache = new FileImportCache<ParcelableKeyRing>(this);
|
||||
FileImportCache<ParcelableKeyRing> cache =
|
||||
new FileImportCache<ParcelableKeyRing>(this, "key_import.pcl");
|
||||
cache.writeCache(selectedEntries);
|
||||
|
||||
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
|
||||
|
||||
@@ -46,10 +46,11 @@ public class FileImportCache<E extends Parcelable> {
|
||||
|
||||
private Context mContext;
|
||||
|
||||
private static final String FILENAME = "key_import.pcl";
|
||||
private final String mFilename;
|
||||
|
||||
public FileImportCache(Context context) {
|
||||
this.mContext = context;
|
||||
public FileImportCache(Context context, String filename) {
|
||||
mContext = context;
|
||||
mFilename = filename;
|
||||
}
|
||||
|
||||
public void writeCache(ArrayList<E> selectedEntries) throws IOException {
|
||||
@@ -64,7 +65,7 @@ public class FileImportCache<E extends Parcelable> {
|
||||
throw new IOException("cache dir is null!");
|
||||
}
|
||||
|
||||
File tempFile = new File(mContext.getCacheDir(), FILENAME);
|
||||
File tempFile = new File(mContext.getCacheDir(), mFilename);
|
||||
|
||||
DataOutputStream oos = new DataOutputStream(new FileOutputStream(tempFile));
|
||||
|
||||
@@ -98,7 +99,7 @@ public class FileImportCache<E extends Parcelable> {
|
||||
throw new IOException("cache dir is null!");
|
||||
}
|
||||
|
||||
final File tempFile = new File(cacheDir, FILENAME);
|
||||
final File tempFile = new File(cacheDir, mFilename);
|
||||
final DataInputStream ois = new DataInputStream(new FileInputStream(tempFile));
|
||||
|
||||
return new Iterator<E>() {
|
||||
|
||||
Reference in New Issue
Block a user