24 Dec Restoring Line messages (with root)
Yesterday I had the "pleasure" of wiping and updating my phone under the assumption that my app backups worked. Imagine my surprise when I booted my phone and saw that Titanium Backup wouldn't restore from backups because they were corrupted! To say I was disappointed would be the understatement of the year! I lost so many things: screenshots, app data, app backups, etc... The only thing I didn't lose were my camera photos, which were thankfully stored on my SD card. All that said, let me first say that the main lesson here is to backup locally and then backup to another location when performing potentially dangerous tasks.
Before updating, I went through the painstaking process of backing up each and every Line conversation I had. As you may know, Line is a [battery-hogging](http://forum.xda-developers.com/nexus-4/help/naver-line-chat-causes-battery-drain-t2179932) chat app that doesn't support multiple devices well, nor does it keep any significant chat history between devices. So I manually backed up all my conversations. On internal storage.
![Facepalm...](/_static/stuff/2016-12-24-face-palm-line.jpg)
So that was all lost. Very fortunately, I had a app backup for Line stored on my Google Drive. So I opened the backup file with 7zip and browsed into the databases folder. Now it should be said that Line does not provide a clear way of restoring messages even with a database file. There are authentication processes associated with each account that only allow an account to be used on one device. So I opened the **backed-up** `naver_line` database using [DB Browser for SQLite](http://sqlitebrowser.org/).
![naver_line database](/_static/stuff/2016-12-24-line-database.png)
I exported the `chat` and `chat_history` tables to an SQL file.
![Chat history tables](/_static/stuff/2016-12-24-chat-history.png)
Then I copied the **current** `naver_line` database file to my computer. This should be located at `/data/data/jp.naver.line.android/databases/`. Make sure that you have opened Line already and have authenticated your phone number so that this database is already "authenticated". Then open this database with the DB Browser. Delete the `chat` and `chat_history` tables in the current database. It should be empty because you shouldn't have any chat history on your new device. Import your previously exported chat history. Save the database and then copy this back to your device at the original location.
This only works if your device is rooted and you mount `/data` as read/write. So there are some limitations. But this is a great reminder that if you enjoy having chat history or you enjoy being in control of your data, make backups and back those up too. I did lose a lot of other information on my phone, but at least it's a bit faster than before, and I did learn some valuable lessons.
![S5 screenshot after update](/_static/stuff/2016-12-24-updated-s5.png)
Comments
Hey Michael! 我是大惠~ 你的國中同學 你現在在台灣嗎? 我們想說要辦一個小型同學會 想問問你是否有空 因為你好像很少用facebook 剛好看到你有這個網站最近也還有更新就來留言了 如果你有看到的話可以加我的line唷 ID:s87147
:)
Hi, there are also online SQLite browsers (https://extendsclass.com/sqlite-browser.html, ..)
Thanks for the heads up!