pages tagged hackNico Schotteliushttps://www.nico.schottelius.org//tags/hack/Nico Schotteliusikiwiki2016-02-25T13:34:32ZHow to extract your Amazon ebooks from the Android Kindle Apphttps://www.nico.schottelius.org//blog/how-to-extract-your-amazon-ebooks-from-the-android-kindle-app/2016-02-25T13:34:32Z2015-02-03T14:47:26Z
<h2>TL;DR</h2>
<p>The ebooks of the Amazon Kindle app can be found on your
Android phone in PRC format below the folder
<strong><em>/data/media/0/Android/data/com.amazon.kindle/files/</em></strong>.</p>
<h2>Download the books</h2>
<p>To be able to extract your books from your Android phone, you need to
synchronise the books first, so they are available on your device.</p>
<p>To ensure they are local. turn of all network connections
(wifi, mobile data) and try to read them.</p>
<h2>Finding the files</h2>
<p>At first I guessed the files I was looking for may be
ending in <strong><em>.azw</em></strong>. Looking for these files, however
did not reveal any file.</p>
<p>My second guess was to look for amazon files or folder
named amazon:</p>
<pre><code>% find / -name \*amazon\* 2>/dev/null
</code></pre>
<p>I found <strong>/data/data/com.amazon.kindle</strong>, with the following content:</p>
<pre><code>% ls
app_com.amazon.device.syncHIGH app_metricsNORMAL databases
app_com.amazon.device.syncNORMAL app_web_cache files
app_dex app_web_database lib
app_dexopt app_webview shared_prefs
app_metricsHIGH cache
</code></pre>
<p>Looking for books in this directory wasn't successful.
However, the databases directory looked interesting.</p>
<pre><code>% cd databases
% grep -ri mybookname *
Binary file databases/kindle_library.db matches
Binary file databases/kindle_library.db-journal matches
</code></pre>
<p>I used sqlite to have a look at the database:</p>
<pre><code>% sqlite3 kindle_library.db
sqlite> .schema
...
</code></pre>
<p>This revealed one interesting table named <strong><em>LocalContent</em></strong>.
Looking at it closer:</p>
<pre><code>sqlite> select * from LocalContent;
</code></pre>
<p>This revealed the emulated path
<strong><em>/storage/emulated/0/Android/data/com.amazon.kindle/files/</em></strong>
and referenced <strong><em>.prc</em></strong> files.</p>
<p>I looked for them in the filesystem using ...</p>
<pre><code>% find / -name \*.prc 2>/dev/null
</code></pre>
<p>... and found my books!</p>
<p>To extract the ebooks to your computer, you can use any file copy program.
The <strong><em>rsync</em></strong> utility however is suited for it very well, as it can
(re-)sychronise the whole folder:</p>
<pre><code>% rsync -av /data/media/0/Android/data/com.amazon.kindle/files/ mycomputer:mybooks/
</code></pre>