How to read data from .db.crypt file ?

12,794

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 !! :)

Share:
12,794

Related videos on Youtube

Noman
Author by

Noman

Senior Android Engineer (Android Apps) with an experience of 9 years. Email me @ [email protected]

Updated on June 04, 2022

Comments

  • Noman
    Noman about 2 years

    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.

    • Lucifer
      Lucifer over 10 years
      Take a deep breath... You should add some of your effort code while asking the question. Also error if any.
  • Kodr.F
    Kodr.F over 10 years
    encrypted cannot be read by sqlite3 directly its need python to crack the information and extract first
  • tianwei
    tianwei over 10 years
    I said this xxx.db.crypt need to be decrypted to a .db file ,not use sqite3 to read directly .
  • Noman
    Noman over 10 years
    See this and if you get any clue then help: stackoverflow.com/questions/22551704/…