2

I am creating an app for personal use only, and for a while now I have been trying to figure out how to connect to a third-party's app's database without sharing content user ID. Note: I have root, so all root options are welcome too!

I have been using this:

protected String RefreshMessages() {
        try {
        String line;
        String result = "";
        Process process = Runtime.getRuntime().exec("su");
        OutputStream stdin = process.getOutputStream();
        InputStream stdout = process.getInputStream();
        stdin.write("su -c 'sqlite3 \"/data/data/<app>/databases/database.db\" \"" + REFRESH_QUERY + "\"'\n".getBytes());
        stdin.write("exit\n".getBytes());
        stdin.flush();
        stdin.close();
        BufferedReader br = new BufferedReader(new InputStreamReader(stdout));
        while((line = br.readLine()) != null){
            result = result + line;
        }
        Log.d("[Output]", result);
        br.close();
        process.waitFor();
        process.destroy();
        return result;
    } catch (Exception ex) {
        Log.d("ERR-RFRSH-MSG", ex.toString());
        return "0";
    }
}

And spamming it in a service as fast as I can to get updates, but seriously.. there has to be a better option available... especially as a root user. Something that allows me to connect properly and get live information from the database. I have literally Google'd for months and this is the best I could find.

I also found stuff about copying the database into a TEMP folder within my app's domain and then reading contents, but I need to read information quick. Constantly copying over the whole database is too slow.

Please tell me I have better options, Android wizards!

Dysanix Official
  • 842
  • 1
  • 10
  • 18
  • I'm assuming you don't have the ability to modify the 3rd party app code? – Nir Duan Jan 22 '17 at 08:29
  • @NirDuan I have tried to reverse engineer the app, add my own content ID and then create the apk with my own KeyStore, but the app did not run anymore. Probably because the entire app is obfuscated and it just doesn't work. I have root access, and you have apps like "SQLite Editor" that can edit all databases with root access. How do they do it? – Dysanix Official Jan 22 '17 at 08:47
  • I have tried chmodding the data/data folder to 777 and open it directly, but that does not work either. – Dysanix Official Jan 22 '17 at 08:49
  • Very interesting, what "SQLite Editor" app you saw working on the market (Let's try to reverse engineer it), is this link helps you: http://stackoverflow.com/a/16169166/6028746 ? – Nir Duan Jan 22 '17 at 08:54
  • @NirDuan That is the method I am currently already using (see main post), I would like to create a direct connection though! (db.openDatabase(,null,0);). Also an SQLEditor that does the trick (but costs money..) is https://play.google.com/store/apps/details?id=com.speedsoftware.sqleditor&hl=en – Dysanix Official Jan 22 '17 at 09:01
  • https://rratmansky.wordpress.com/2013/04/05/access-another-apps-database/ I found this, but I just get this error: unknown error (code 14): Could not open database -- I added the right permissions to my manifest and gave root permissions. – Dysanix Official Jan 22 '17 at 09:12

0 Answers0