mueller-ma / PrepaidBalance

App to check your prepaid balance
Apache License 2.0
36 stars 12 forks source link

Export to CSV fails #186

Closed brotzeller closed 1 year ago

brotzeller commented 1 year ago

Step to reproduce

Click "Export to CSV" in the app menu.

Expected result

Data gets exported.

Actual result

Toast reading "Export failed" and no CSV file is generated.

Logcat has

MainActivity: Error saving file
MainActivity: java.io.FileNotFoundException: open failed: EACCES (Permission denied)
MainActivity:  at android.os.ParcelFileDescriptor.openInternal(ParcelFileDescriptor.java:313)
MainActivity:  at android.os.ParcelFileDescriptor.open(ParcelFileDescriptor.java:211)
MainActivity:  at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1297)
MainActivity:  at android.content.ContentResolver.openOutputStream(ContentResolver.java:1062)
MainActivity:  at android.content.ContentResolver.openOutputStream(ContentResolver.java:1038)
MainActivity:  at com.github.muellerma.prepaidbalance.ui.MainActivity.writeToFileInDownloads(MainActivity.kt:163)
MainActivity:  at com.github.muellerma.prepaidbalance.ui.MainActivity.access$writeToFileInDownloads(MainActivity.kt:33)
MainActivity:  at com.github.muellerma.prepaidbalance.ui.MainActivity$exportAsCsv$1.invokeSuspend(MainActivity.kt:137)
MainActivity:  at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
MainActivity:  at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
MainActivity:  at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42)
MainActivity:  at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
MainActivity:  at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
MainActivity:  at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
MainActivity:  at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
MainActivity:  at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)

This is on a Samsung device running Android 9.

mueller-ma commented 1 year ago

I cannot reproduce this issue and when searching for this exception I only find solutions for Android >11.

Ohior commented 1 year ago

csv is just a .txt file, that separate data using "comma". If you want I can try and fix the issue

mueller-ma commented 1 year ago

Sure, you can give it a try. There's a button in the app that should create a csv file and export it to the "Downloads" folder on the device. But for some reason the export fails here.

Ohior commented 1 year ago

I made a PR for this fix. It works now.