Skip to content

Add 'Use default collection folder' recovery option for collection path mismatch#20362

Open
Giyutomioka-SS wants to merge 1 commit intoankidroid:mainfrom
Giyutomioka-SS:collection-path-mismatch-17524
Open

Add 'Use default collection folder' recovery option for collection path mismatch#20362
Giyutomioka-SS wants to merge 1 commit intoankidroid:mainfrom
Giyutomioka-SS:collection-path-mismatch-17524

Conversation

@Giyutomioka-SS
Copy link
Contributor

@Giyutomioka-SS Giyutomioka-SS commented Feb 25, 2026

Purpose / Description

When the stored collection path is wrong or no longer exists (e.g. legacy vs app-specific path), the "Error handling" screen had no way to fix it. This change adds a "Use default collection folder" option on that screen so the user can reset the path to the default and exit. On the next launch the app opens from the correct folder or creates a new collection there.

Fixes

Approach

When the database error dialog appears, we show a new "use default folder" option only if the current folder is not already the default one. If the user taps it, we close the collection, reset the folder path back to default, and exit the app. Next time the app opens, it uses the default folder. This follows the same close-reset-finish pattern already used elsewhere in the app.

How Has This Been Tested?

Reproduced the bug by setting a wrong path in prefs and a fake DB at that path on emulator.

Screen Recording

Screen_recording_20260225_172356.webm

Checklist

Please, go through these checks before submitting the PR.

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

@github-actions
Copy link
Contributor

Important

Maintainers: This PR contains Strings changes

  1. Sync Translations before merging this PR and wait for the action to complete
  2. Review and merge the auto-generated PR in order to sync all user-submitted translations
  3. Sync Translations again and merge the PR so the huge automated string changes caused by merging this PR are by themselves and easy to review

@criticalAY
Copy link
Contributor

criticalAY commented Feb 25, 2026

I am not able get how you reproduced it, you edited the pref in data/data...? could you mention the exact steps

@criticalAY criticalAY added the Needs Author Reply Waiting for a reply from the original author label Feb 25, 2026
@Giyutomioka-SS
Copy link
Contributor Author

@criticalAY On an Android 14 emulator with fullDebug (com.ichi2.anki.debug):

  1. Install and launch once so a normal collection is created at the default path, then close the app.

  2. Change the stored collection path in prefs to a bad location:

    adb shell run-as com.ichi2.anki.debug \
    "sed -i 's#/storage/emulated/0/AnkiDroid#/storage/emulated/0/Android/com.ichi2.anki.debug/files/AnkiDroid#g' shared_prefs/com.ichi2.anki.debug_preferences.xml"
    
  3. Put a fake DB only at that bad path:

    adb shell 'rm -rf /storage/emulated/0/Android/com.ichi2.anki.debug/files/AnkiDroid && \
    mkdir -p /storage/emulated/0/Android/com.ichi2.anki.debug/files/AnkiDroid && \
    echo "not a real sqlite db" > /storage/emulated/0/Android/com.ichi2.anki.debug/files/AnkiDroid/collection.anki2'
    
  4. Force stop and relaunch the app:

    adb shell am force-stop com.ichi2.anki.debug
    adb shell monkey -p com.ichi2.anki.debug -c android.intent.category.LAUNCHER 1
    
  5. You should see “Collection not opened” then, after tapping Options, the Error handling dialog with the new “Use default collection folder” option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Author Reply Waiting for a reply from the original author Needs Review Strings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Collection not opened" is not actionable if the collection path no longer exists

2 participants