Reputation: 4109
I want to read data as string from .db.crypt file
Is there any lib or method to decrypt data from this file ?
If Yes then kindly point me in direction or provide any sample.
Upvotes: 8
Views: 14657
Reputation: 4109
I have done this by using following code:
public void copyDbToSdcard()
{
try
{
String comando = "cp -r /data/data/com.whatsapp/databases/msgstore.db /sdcard/My_Custom_Folder/";
Process suProcess = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(suProcess.getOutputStream());
os.writeBytes(comando + "\n");
os.flush();
os.writeBytes("exit\n");
os.flush();
try
{
int suProcessRetval = suProcess.waitFor();
if(255 != suProcessRetval)
{
//
}
else
{
//
}
}
catch (Exception ex)
{
Log.e("ERROR-->", ex.toString());
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
private void openAndQueryDatabase()
{
try
{
DataBaseHelper dbHelper = new DataBaseHelper(this.getApplicationContext());
newDB = dbHelper.getWritableDatabase();
Cursor c = newDB.rawQuery("SELECT data FROM messages where data!=''", null);
if(c != null)
{
if(c.moveToFirst())
{
do
{
String data = c.getString(c.getColumnIndex("data"));
results.add(data); //adding to arrayList
}
while (c.moveToNext());
}
}
while (c3.moveToNext());
}
}
}
catch (SQLiteException se)
{
Log.e(getClass().getSimpleName(), "Could not create or Open the database");
}
}
And then display results in your TextView or whereever you want.
Cheers !! :)
Upvotes: 1
Reputation: 1879
I think .db.crypt
is just a suffix defined by someone. For example, I can make a text file and name it abc.db.crypt
. So you can not do anything just by knowing the suffix.
But sometimes the suffix is a clue to find the way to your solution. I guess this file is a database file which has been encrypted first. So what you need to do is to find the encrypt method(maybe DES or some algorithm just defined by the author), decrypt the file to a database file(xxx.db) and then use sqlite3 to get data from it.
Upvotes: 0