Hi,
Question ilnk on Stack over
flow<http://stackoverflow.com/questions/11812549/android-file-working-in-emulator-but-giving-error-in-device>
I am just trying to upload file to server through the code it working fine
if I access file from Emulator,
path *data/app/07312012_135528.3gp* and gets server response *200, OK*
but when I access file to upload through Device is gives error *400, Bad
Request* while file is present in *SDCard* and it passes the
*File.exists()*check.
My Phone is *Samsung Galaxy Ace*
HttpPost postRequest = new HttpPost(ServerURL);
MultipartEntity reqEntity = new MultipartEntity();
File dir = Environment.getExternalStorageDirectory();
File yourFile = new File(dir, "tdsongdata/07312012_135528.3gp");
// path becomes "/mnt/sdcard/tdsongdata/07312012_135528.3gp"
if(yourFile.exists())
{
reqEntity.addPart("email", new StringBody("[email protected]"));
reqEntity.addPart("password", new StringBody("123"));
reqEntity.addPart("title", new StringBody("The new file"));
reqEntity.addPart("musicData", new FileBody(yourFile));
}
But When I *try to play it from the same path in Device it plays the Audio
successfully*
MediaPlayer mp = new MediaPlayer();
try {
mp.setDataSource("/mnt/sdcard/tdsongdata/07312012_135528.3gp");
mp.prepare();
mp.start();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
I could not understand where the problem is, please help
-----------------
Best Regards,
Muhammad Azhar
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en