# (Java API) Support for finding/deleting notes

**URL:** <https://forums.ankiweb.net/t/java-api-support-for-finding-deleting-notes/58941>\
**Category:** Suggestions\
**Created:** [April 12, 2025, 10:59pm UTC](https://forums.ankiweb.net/t/java-api-support-for-finding-deleting-notes/58941 "2025-04-12T22:59:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hashcod3](https://avatars.discourse-cdn.com/v4/letter/h/71e660/32.png) [@Hashcod3](https://forums.ankiweb.net/u/Hashcod3)\
**Post date:** [April 12, 2025, 10:59pm UTC](https://forums.ankiweb.net/t/java-api-support-for-finding-deleting-notes/58941/1 "2025-04-12T22:59:01Z")

</div>

(Regards this API api/src/main/java/com/ichi2/anki/api/AddContentApi.kt and [Third Party Apps · ankidroid/Anki-Android Wiki · GitHub](https://github.com/ankidroid/Anki-Android/wiki/Third-Party-Apps))

Right now, editing existing notes through the AnkiDroid API isn’t very practical. You can update notes if you have their `noteId`, but that means third-party apps have to keep track of all those IDs themselves - which is pretty inconvenient and easy to mess up.  
It’d be a lot easier if the API let you search for notes based on field content (like the front of the card) to get the `noteId` when needed. Also, some way to delete notes through the API would be also good, but I guess this would be a bit sensitive.

---

<div class="post-metadata">

**Author:** ![licryle](https://avatars.discourse-cdn.com/v4/letter/l/ecae2f/32.png) [@licryle](https://forums.ankiweb.net/u/licryle)\
**Post date:** [May 9, 2025, 12:57pm UTC](https://forums.ankiweb.net/t/java-api-support-for-finding-deleting-notes/58941/2 "2025-05-09T12:57:57Z")

</div>

I ran into the same issue (deleting) and wanted to find some answers before coding it myself, so I found your post… then coded it myself 🙂

Deleting is definitely supported, and I suspect the search too.  
You have to implement it yourself, and sadly… you can’t use the existing class.

You can wrap it, implement the rest, and you may want to compromise (I won’t be doing compat for old versions etc.)

Here it is for deleting: [Android-HSKFlashcardsWidget/app/src/main/java/fr/berliat/hskwidget/data/dao/AnkiNotesDAO.kt at master · licryle/Android-HSKFlashcardsWidget · GitHub](https://github.com/licryle/Android-HSKFlashcardsWidget/blob/master/app/src/main/java/fr/berliat/hskwidget/data/dao/AnkiNotesDAO.kt)

The reference in Anki’s code is here: [Anki-Android/api/src/main/java/com/ichi2/anki/api/AddContentApi.kt at main · ankidroid/Anki-Android · GitHub](https://github.com/ankidroid/Anki-Android/blob/main/api/src/main/java/com/ichi2/anki/api/AddContentApi.kt)

Note that deleting works but crashes Anki when opening the UI. Filed here: Anki-Android/issues/18294

---

<div class="post-metadata">

**Author:** ![licryle](https://avatars.discourse-cdn.com/v4/letter/l/ecae2f/32.png) [@licryle](https://forums.ankiweb.net/u/licryle)\
**Post date:** [May 11, 2025, 5:34pm UTC](https://forums.ankiweb.net/t/java-api-support-for-finding-deleting-notes/58941/3 "2025-05-11T17:34:24Z")

</div>

I realized I pasted one of the wrong links – this is better to study available APIs.

Check out the functions:  
fun update  
fun insert  
fun query  
fun delete

> <https://github.com/ankidroid/Anki-Android/blob/main/AnkiDroid/src/main/java/com/ichi2/anki/provider/CardContentProvider.kt>

---

<div class="post-metadata">

**Author:** ![Kadisonm](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/kadisonm/32/28775_2.png) [@Kadisonm](https://forums.ankiweb.net/u/Kadisonm)\
**Post date:** [June 3, 2025, 4:36pm UTC](https://forums.ankiweb.net/t/java-api-support-for-finding-deleting-notes/58941/4 "2025-06-03T16:36:14Z")

</div>

Would this allow for editing a note’s fields within a card template? Trying to figure out how to with the API.

Edit:  
Apologies, got this mixed up with the javascript api.
