1

I am currently attempting to write a program in Netbeans that will allow me to click a few buttons to do different things.

First I need a button to copy files from certain location on a Smartwatch to a new directory on the same device(SDcard)

Then I am looking to write a script/code to extract the data from the SDcard directory to the host machine, where the final step is looking at the .db files on the windows PC.

Simply put, I need to make a program to copy a DB file from one location to a new directory, then I need to extract it to the host machine it is plugged into.

Sorry if this seems a little disjointed but I'm looking for help writing it as

If you need any further information, please let me know.

EDIT -

I know I need to use -

cat /data/data/com.google.android.gms/databases/node.db > /sdcard/node.db

This will copy the db file I need onto a place where I can use ADB to extract it from.

Secondly I need to use -

Adb pull /sdcard/node db

This will save the node DB file to the directory where SDK is.

I'm just unsure how to get this to be included on an ONCLICK button in my Java Program.

Jhillips
  • 21
  • 1
  • 5

2 Answers2

1

Basic code for running shell commands:

Process p = Runtime.getRuntime().exec( "ls -l" );
p.waitFor();

BufferedReader reader = new BufferedReader( new InputStreamReader( p.getInputStream() ) );

String line = "";
while ((line = reader.readLine())!= null) {
    System.out.println( "line : " + line);
}

You can also pass arguments like that:

Process p = Runtime.getRuntime().exec(new String[]{ "ls", "-l",} );
RonTLV
  • 2,376
  • 2
  • 24
  • 38
0

You can also try using Apache Commons Exec library. Check tutorial here.

String line = "calc.exe";
CommandLine cmdLine = CommandLine.parse(line);
DefaultExecutor executor = new DefaultExecutor();
int exitValue = executor.execute(cmdLine);
Greg Witczak
  • 1,634
  • 4
  • 27
  • 56