From 1974f98e7fd02b60c46fe2b9c3eb4c6ae25b5c1b Mon Sep 17 00:00:00 2001 From: Rinaldy Adin <16521390@mahasiswa.itb.ac.id> Date: Fri, 5 Apr 2024 08:48:37 +0700 Subject: [PATCH] chore: use cache path for email --- app/src/main/java/com/example/abe/MainActivityViewModel.kt | 4 ++-- app/src/main/res/xml/filepaths.xml | 6 +----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/example/abe/MainActivityViewModel.kt b/app/src/main/java/com/example/abe/MainActivityViewModel.kt index 632c54d..5f02820 100644 --- a/app/src/main/java/com/example/abe/MainActivityViewModel.kt +++ b/app/src/main/java/com/example/abe/MainActivityViewModel.kt @@ -48,7 +48,7 @@ class MainActivityViewModel(private val transactionRepository: TransactionReposi suspend fun createEmailIntent(context: Context, user: String): Intent { clearExportCacheFiles(context) - val newFile = File(context.externalCacheDir, if (newExcelFormat) "export.xlsx" else "export.xls") + val newFile = File(context.cacheDir, if (newExcelFormat) "export.xlsx" else "export.xls") val contentUri = FileProvider.getUriForFile(context, "com.example.abe.fileprovider", newFile) exportTransactionsToExcel(context.contentResolver, contentUri, user) @@ -66,7 +66,7 @@ class MainActivityViewModel(private val transactionRepository: TransactionReposi } fun clearExportCacheFiles(context: Context) { - context.externalCacheDir?.apply { + context.cacheDir?.apply { val files = listFiles() ?: emptyArray() files.forEach { file -> if (file.name.startsWith("export")) diff --git a/app/src/main/res/xml/filepaths.xml b/app/src/main/res/xml/filepaths.xml index 405a83d..fe2c7dc 100644 --- a/app/src/main/res/xml/filepaths.xml +++ b/app/src/main/res/xml/filepaths.xml @@ -1,10 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <paths> - <external-cache-path + <cache-path name="exports" path="/" /> - -<!-- <cache-path--> -<!-- name="exports"--> -<!-- path="/" />--> </paths> \ No newline at end of file -- GitLab