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!