How to make a QByteArray from a Database file
<p>Using <a href="http://doc.qt.io/qt-5/qiodevice.html#readAll" rel="nofollow">QByteArray QIODevice::readAll()</a> from QT5, I was able to make a bytes array from a txt file or an image, used decode after and recreated the file correctly. But, when I tried with a .db file (SQLITE) it didn't work. </p>

<p>I noticed that when you open a .db with a text editor, you will see "SQLite format 3" followed by encoded characters. After making a QByteArray from a .db file, followed by decode() to recreate the file, when I opened it with a text editor, the file only contains the text "SQLite format 3".</p>

<p>Does QByteArray only work with txt file or Image file? </p>

<p>If it does, how can I make a Array of bytes from a .db (SQLITE) file.</p>

<p>Thanks</p>

<hr>

<p>Update1 (The code belows works):</p>

<pre><code>QFile file("C:/database.db");
if(!file.open(QIODevice::ReadOnly))
    qDebug()&lt;&lt;"You are stupid!";

QByteArray byteArray = file.readAll();

QFile file2("C:/database2.db");
file2.open(QIODevice::WriteOnly);
file2.write(byteArray);

file2.close();
file.close();
</code></pre>

<hr>

<p>Update2:</p>

<p>About the decode I mentioned in my initial question, I was using the following: </p>

<pre><code>QString QFile::decodeName(const QByteArray &amp; localFileName)
</code></pre>

<p>which make no sense when you read carefully the documentation and was just wrong. :)</p>