Thanks Mega for looking into this
I am seeing the sdcard from the emulator..When i start the emulator i have
given the option in eclipse of the location of the sdcard.So after i
download the file I want to view this file in the SDcard.I only see this the
file in the DDMS mode,so the file has actually been downloaded.But I have
not been able to figure out as to what stops me from seeing the file in the
sdcard.
Thanks
Guru
On Fri, Oct 17, 2008 at 12:28 PM, Megha Joshi <[EMAIL PROTECTED]> wrote:
>
>
> 2008/10/15 guru <[EMAIL PROTECTED]>
>
>>
>> I needed to download a file and store it in my sdcard.I first save it
>> by writing in the output stream(by using openFileOutput) in the
>> application package.From here I copy it to my SDCard and its written
>> on my SDCard.But when i see my SDCard in the file in the DDMS mode i
>> am able to see that file,
>
>
> If you see the file on your sdcard in the ddms file explorer it should be
> there.
>
>
>> but in the SDCard i was not able to see that
>> file.
>
>
> Its not clear how you are viewing the sdcard in this case.
>
>
>
>> Please could anyone tell how can this be acheived.
>>
>>
>> heres the code snippet i use.
>>
>> String fileName = "myFileName";
>> File bufferedFile = new File("/sdcard/"+fileName);
>> copyFiletoSDCard(downloadingMediaFile,bufferedFile.getAbsolutePath());
>>
>> private void copyFiletoSDCard(File fromFile, String fileName) {
>> FileInputStream from = null;
>> FileOutputStream to = null;
>> try {
>> from = context.openFileInput(fromFile.getName());
>> to = new FileOutputStream(fileName);
>> byte[] buffer = new byte[4096];
>> int bytesRead;
>>
>> while ((bytesRead = from.read(buffer)) != -1)
>> to.write(buffer, 0, bytesRead); // write
>> } catch(IOException ioException){
>> Log.i(getClass().getName(),"ioException Msg");
>>
>> Log.i(getClass().getName(),ioException.getMessage());
>> ioException.printStackTrace();
>> }finally {
>> if (from != null)
>> try {
>> from.close();
>> } catch (IOException e) {
>> ;
>> }
>> if (to != null)
>> try {
>> to.close();
>> } catch (IOException e) {
>> ;
>> }
>> }
>>
>> }
>>
>>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---