Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
sir,

i am using client-server method to send a .mp3 file from android mobile to server.By using following code a folder is created,that is stored in my internal storage. i am new to android.

code
Java
private String getFilePath() { // TODO Auto-generated method stub

     String filePath = Environment.getExternalStorageDirectory().getPath();
        File file = new File(filePath, "MediaRecorderSample");
        if (!file.exists())
            file.mkdirs();
        return (file.getAbsolutePath() + "/" + System.currentTimeMillis() + .mp3);
    }

The .mp3 file properties, it is showing the path as
Internal Storage/MediaRecorderSample/142324.mp3. I tried these paths
"Internal Storage/MediaRecorderSample/142324.mp3" , "/storage/emulated/0/142324.mp3", "/mnt/sdcard//MediaRecorderSample/142324.mp3 to send file.
but at the server side i am getting 0kb file.is it because of file path or some other problem.Please suggest me solution to fix this.


Thanks
Posted
v2
Comments
Richard MacCutchan 2-Aug-15 3:11am    
The location of your file on the Android system has no relevance to where it is stored on the server. It is more likely that either your file path is incorrect, or there is a bug in your send/receive protocol. See http://www.codeproject.com/Articles/816470/Handling-Input-and-Storage-on-Android for useful information on handling storage on Android.
Member 10009139 2-Aug-15 7:01am    
The protocol is working fine for image,but not for audio file.
Richard MacCutchan 2-Aug-15 7:33am    
Then you are doing something wrong. But we cannot begin to guess what that may be. You will need to use your debugger to collect more inforation on what is happening when your code runs.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900