java - i want to transfer data from pc to android phone for which i am using the following code, i am not able to get working directory -
i getting followin error in code:
java.io.ioexception: error running exec(). command: ["/adb", -s, 9774d56d682e549c, push, "c:\documents, and, settings\my, documents\other\music\b.wma, ", \sdcard\music] working directory: null environment: null
public class transferdata extends activity { private string device_id ; private string = "c:\\documents , settings\\my documents\\other\\music\\b.wma "; private string ="\\sdcard\\music"; private static final string adb_push = "\"" /*+ utility.getworkdir()*/ + file.separator + "adb\" -s %s push \"%s\" %s"; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.splash); device_id = secure.getstring(getbasecontext().getcontentresolver(),secure.android_id); push(device_id,from,to); } /** pushes file connected device via adb * @param deviceid device serial number * @param path of source file (on pc) * @param 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 = 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); } } }
you can not access computer disk drive android.
just keep b.wma in assets folder .
then use following code use b.wma
try { inputstream = context.getassets().open(url); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } hope helps you.
Comments
Post a Comment