Skip to content
Snippets Groups Projects
Commit 1974f98e authored by Rinaldy Adin's avatar Rinaldy Adin
Browse files

chore: use cache path for email

parent 3f177e5c
Branches
Tags
1 merge request!19Feat/twibbon
...@@ -48,7 +48,7 @@ class MainActivityViewModel(private val transactionRepository: TransactionReposi ...@@ -48,7 +48,7 @@ class MainActivityViewModel(private val transactionRepository: TransactionReposi
suspend fun createEmailIntent(context: Context, user: String): Intent { suspend fun createEmailIntent(context: Context, user: String): Intent {
clearExportCacheFiles(context) 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 = val contentUri =
FileProvider.getUriForFile(context, "com.example.abe.fileprovider", newFile) FileProvider.getUriForFile(context, "com.example.abe.fileprovider", newFile)
exportTransactionsToExcel(context.contentResolver, contentUri, user) exportTransactionsToExcel(context.contentResolver, contentUri, user)
...@@ -66,7 +66,7 @@ class MainActivityViewModel(private val transactionRepository: TransactionReposi ...@@ -66,7 +66,7 @@ class MainActivityViewModel(private val transactionRepository: TransactionReposi
} }
fun clearExportCacheFiles(context: Context) { fun clearExportCacheFiles(context: Context) {
context.externalCacheDir?.apply { context.cacheDir?.apply {
val files = listFiles() ?: emptyArray() val files = listFiles() ?: emptyArray()
files.forEach { file -> files.forEach { file ->
if (file.name.startsWith("export")) if (file.name.startsWith("export"))
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<paths> <paths>
<external-cache-path <cache-path
name="exports" name="exports"
path="/" /> path="/" />
<!-- <cache-path-->
<!-- name="exports"-->
<!-- path="/" />-->
</paths> </paths>
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment