机器人:从PC通过USB编程传输SQLite数据库到设备 [英] android: transfer sqlite database from pc to device via usb programatically
问题描述
的情况是这样的。我已经写在vb.net中的应用程序。它由两个部分组成。一个在PC上,另一手持的Windows Mobile 6设备上。桌面程序一个SQLServer压缩数据库往返于通过USB使用ActiveSync手持设备。可能我们要寻找到具有Android的手持设备也支持此应用程序。现在我知道我可以使用SQLite与.NET。我知道我可以使用亚行推拉数据(因此数据库文件),并从设备。
The situation is this. I have an application written in vb.net. it consists or two parts. One on a PC and the other on a handheld windows mobile 6 device . The desktop program transfers a SQLServer compact database to and from the handheld device using activesync via USB. Potentially we want to look into having android handheld devices also supported by this application. Now I know I can use SQLite with .net. I know I can use ADB to push and pull data (and therefore the database files) to and from the device.
我需要知道的是,我可以直接从VB.NET访问亚洲开发银行作为一个API或SDK,而不是做手工。
What I need to know is can I access ADB directly from VB.NET as an API or SDK rather than having to do it manually.
当然,除非我失去了一些东西,我可以以其他方式复制数据库,并从设备?
Unless of course I'm missing something and I can copy databases to and from the device in some other way?
由于预期
推荐答案
有没有直接的API为。我们有一个类似的场景,其中用户从桌面客户端同步的内容(也即数据库)(在我们的基础的情况下的Java Swing),其中手动使用亚洲开发银行和它的正常工作为止。
There's no direct API for that. We have a similar scenario, where the user syncs content (i.e. also the database) from a desktop client (in our case Java Swing based), which utilized adb manually and it's working fine so far.
在我们的Java客户端,我们会打电话来:
In our java client, we'd call:
private static final String ADB_PUSH = "\"" + Utility.getWorkDir() + File.separator + "adb\" -s %s push \"%s\" %s";
/**
* Pushes a file to a connected device via ADB
* @param deviceId Device serial number
* @param from Path of source file (on PC)
* @param to Path of file destination (on device)
*/
public static void push(String deviceId, String from, String to) {
try {
String cmd = String.format(ADB_PUSH, deviceId, from, to);
System.out.println("adb push: " + cmd);
Process p = Runtime.getRuntime().exec(cmd);
InputStream is = p.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line;
while ((line = br.readLine()) != null) {
System.out.println("adb: " + line);
}
} catch (IOException e) {
System.out.println(e);
}
}
这篇关于机器人:从PC通过USB编程传输SQLite数据库到设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!