I'm newbe in android development.
I bulid app for automatic downloader,
every downloads work properly and save on my sd card, but the drm file not open on device.
I explain my self, I try download file with extension dd\dm, If the regular browser download dd\dm files, the device extract them to dcf extension.
my app not do that... I notied then if my device do restart, every is right, in fact the device change the extension of this file to dcf, and i can play this song, If i didnt originator restart to device, the files extension stay on .dd.dm
mt content type is: application/vnd.oma.drm.message
Somebody knows how i need care of that??
This Is my code.....
class DownloadFileFromURL extends AsyncTask<String, String, String> {
/**
* Before starting background thread
* Show Progress Bar Dialog
* */
@Override
protected void onPreExecute() {
super.onPreExecute();
showDialog(progress_bar_type);
}
/**
* Downloading file in background thread
* */
@Override
protected String doInBackground(String... f_url) {
int count;
try {
URL url = new URL(f_url[0]);
URLConnection conection = url.openConnection();
conection.getContent();
conection.connect();
// getting file length
int lenghtOfFile = conection.getContentLength();
// Insert Information Of File to Array
getCurrentArray()[index].setSizeOfFile(OrangeFile.convertToStringRepresentation(lenghtOfFile));
getCurrentArray()[index].setMimeOfFile(conection.getContentType());
// input stream to read file - with 8k buffer
InputStream input = new BufferedInputStream(url.openStream(), 8192);
// Output stream to write file
OutputStream output = new FileOutputStream(mPath + getCurrentArray()[index].getNameOfFile() + "." + getCurrentArray()[index].getExtOfFile());
byte data[] = new byte[1024];
long total = 0;
while ((count = input.read(data)) != -1) {
total += count;
// publishing the progress....
// After this onProgressUpdate will be called
publishProgress(""+(int)((total*100)/lenghtOfFile));
// writing data to file
output.write(data, 0, count);
}
// flushing output
output.flush();
// closing streams
output.close();
input.close();
} catch (Exception e) {
Log.e("Error: ", e.getMessage());
}
return null;
}