Retrieve database or any other file from the Internal Storage using run-as

后端 未结 12 2361
清酒与你
清酒与你 2020-11-22 11:01

On a non-rooted android device, I can navigate to the data folder containing the database using the run-as command with my package name. Most files types I am c

12条回答
  •  一向
    一向 (楼主)
    2020-11-22 11:47

    Here's a solution that works on a device running Android 5.1. The following example is for Windows.

    You need sed (or sed.exe on windows, e.g. from cygwin.) ( On Unix, it'll just be there ;) ). To remove bad '\r' characters, at least on windows.

    Now just run the following command:

    adb exec-out "run-as com.yourcompany.yourapp /data/data/com.yourcompany.yourapp/databases/YourDatabaseName" | c:\cygwin\bin\sed.exe 's/\x0D\x0A/\x0A/'>YourDatabaseName.db
    

    The sed command strips out trailing /r characters.

    Of course you should replace "com.yourcompany.yourapp" with the package name of the app and "YourDatabaseName" with the name of the database in the app.

提交回复
热议问题