[One (M8) Q&A, Help & Troubleshooting] doublehp:
State of art:

For every one: the classic user dictionary is in /data/data/com.android.providers.userdictionary/databases/user_dict.db as SQLite3 . It's very easy to extract:

echo "SELECT word FROM words;" | sqlite3 /data/local/tmp/user_dict.db | sort | uniq | sed ':a;N;$!ba;s/\n/\|/g' > /data/local/tmp/PersonalDictionary.htcudb

providing you have SQLite3 somewhere in your PATH.

The base HTC IME dictionary is here: /data/data/com.htc.sense.ime/app_db/dlm_export

The SD backup is not on emulated (I have asked for emulated SD from internal memory), but on real physical external SD:

/storage/ext_sd/.data/HTC_IME/PersonalDictionary

The method to find the two last files were:

- touch /data/local/tmp/plop

- make a change in the dic, or a backup

- find /storage/ext_sd/ -newer /data/local/tmp/plop

or

- find /data/data -newer /data/local/tmp/plop

You have to re-touch the plop each time.

Once /data/data/com.android.providers.userdictionary/databases/user_dict.db is exported into /data/local/tmp/PersonalDictionary.htcudb, two things are possible:

- copy the file into /storage/ext_sd/.data/HTC_IME/PersonalDictionary, and make a manual import from HTC Sense Input dictionary manager

- attach the file to an email, and open the attachement from HTC-Mail, what will restaure the attached backup.

I have found the following command to ask for restauring the backup:

am start -a android.intent.action.VIEW -d "content:" -t "application/ime-config" -n com.htc.sense.ime/.ui.RestoreUDB -f "0x00080001"

But I do not get the confirmation toast. Because I don't find where the cache file is stored by HTC-Mail, for IME. Since I run stuff from scripts, that command does not work as is; in my case, I have to run it in this context:

setprop service.adb.tcp.port 5555
stop adbd
start adbd
adb connect 127.0.0.1
adb shell id
adb shell su -c id
adb shell su -c am start [...]

otherwise I get a nasty error about permission issues:

Work for an other day:

- try to construct the am start call for backup restauration from SD (previous line was for email attachement) => give up

- find how to export and rebuild (via script) /data/data/com.htc.sense.ime/app_db/dlm_export

- find if this dictionary is gaining, or loosing any word => stats now on way: cron is recording daily the size of files

- remove dups from /data/data/com.android.providers.userdictionary/databases/user_dict.db (clean PROVIDER file)

- during export, I want to inject Contact details (first name, name, town name)

*** *** ***

The base problem I have is that HTC Sens keyboard is very good, for daily use, but randomly looses settings, and parts of the dics (some times words added the last days; some times 98% of it, only keeping 10 or 15 words).

I want to monitor the IME dic, and produce a system alert when this dic is found to have lost words, and after user confirmation, restaure the IME dic (with an older version of the file, or by rebuilding it).

Some other files may be interesting, in the same folder: mdb_contact_name seem to be a raw text version of com.android.providers.userdictionary/databases/user_dict.db . stm_dump is also very large. IME dictionary has a concept of alias (and auto-replace); but I don't know where this is stored. I also wonder where the word usage statistics are stored (for suggestions).

The big minus I found in this keyboard is that suggestions are always limited to 3 words on the first line (the one always available) (in portrait); Gingerbread and Hackers offer up to 12 words: as much as they can print on screen. Also, suggestions only include literal words: words with letters only; it never suggests words with numbers (unless I already typed one in currect word) or punctuation (statistics show that some words are very often followed by question mark, comma, or full stop).

Now that I am used to the height of HTC Sens keyboard, I make many typos with smaller boards; but smaller boards leave much more screen space for chat. Sens is very good for writing emails; but instant messaging like Skype and Yahoo use too much screen space, and smaller kbd would leave more chat history visible. But Sens has a better word prediction for intuitive chat ...

***

Recoding daily stats of files:

find /data/data/com.htc.sense.ime/app_db/dlm_export.history -mtime 0 | grep "e" || {
for i in dlm_export mdb_contact_name stm_dump
do
{ echo -n "$(date +%Y-%m-%d_%H-%M-%S) : " ; ls -l /data/data/com.htc.sense.ime/app_db/$i | awk '{print $4}' ; } >> /data/data/com.htc.sense.ime/app_db/${i}.history
done

This code will work even with non existing history. Then wait history is 1D old .... I have found that one history per file is easier to re-read than one for all. Injecting date this way date +%Y-%m-%d_%H-%M-%S ; echo -n " : " used to introduce an undesired NL..