Save a ringtone of resources on SD card

I have a mp3 file in my resources folder and I can't figure out how to convert the file into a byte [], so that I can use the command "write" OutputStream. The code below is the method to open the connection and save the file. The only problem is the 'outStream.write (audioFile) '... I don't know how to define audioFile.

try {
    // Create folder if not already created
    FileConnection fc = (FileConnection)Connector.open("file:///SDCard/BlackBerry/ringtones/");
    if (!fc.exists())
        fc.mkdir();
    fc.close();

    // Create file
    fc = (FileConnection)Connector.open("file:///SDCard/BlackBerry/ringtones/" + audioClip, Connector.READ_WRITE);
    if (!fc.exists())
        fc.create();
    OutputStream outStream = fc.openOutputStream();
    outStream.write(audioFile);
    outStream.close();
    fc.close();

    Dialog.alert("Ringtone saved to BlackBerry SDcard.");
} catch (IOException ioe) {
    Dialog.alert(ioe.toString());
}

Is there a way to convert a mp3 file in the folder of resources for a byte [] if I can use the above method? Or y at - it another way to save the audio file? This is my first BlackBerry app and I would greatly appreciate pointers. Thank you.

Take a look at the Class. getResourceAsStreammethod. You can convert InputStream byte [] using IOUtilities.streamToBytes.

Tags: BlackBerry Developers

Similar Questions

  • Cannot run the screen saver because it requires a newer video card or one that is compataible with Direct3D.

    Hello

    I recently rebooted my computer; (Packard Bell) and now cannot run games or screen savers because it does not start. I think my problem has something to do with a Direct3D card? When I run screensavers, I get this message:
    Cannot run the screen saver because it requires a newer video card or one that is compataible with Direct3D.
    I have the impression that sound when I run the 3D games, such as minecraft or GMOD.
    I run on Windows Vista Edition Home Premium and does not do anything but re - install my computer because it wouldn't start.
    It is not as if the graphics card is not there, so I'm really confused!
    Please help me, like playing games is my favorite thing. ;)
    Charlie
    I also ran minecraft to double check and I got this error code:
    Bad video card drivers!
    -----------------------
    Minecraft could not start because it did not find an accelerated OpenGL mode.
    Generally, this can be corrected by updating the video card drivers.
    -BEGIN 7fe0271 error REPORT-
    Generated 10/10/12 21:04
    -Minecraft Version: 1.3.2
    -Operating system: Windows Vista (x 86) version 6.0
    -Java Version: 1.7.0_07, Oracle Corporation
    -Version Java VM: Java hotspot Client VM (mixed mode), Oracle Corporation
    -Memory: 422585352 bytes (403 MB) / 518979584 bytes (494 MB) up to 1037959168 bytes (989 MB)
    -JVM Flags: 2 total; Xms512m-Xmx1024m
    -LWJGL: 2.4.2
    -OpenGL: ~ ERROR ~ NullPointerException: null
    -Is Modded: Probably not
    -Type: customer
    -Texture Pack: ~ ERROR ~ NullPointerException: null
    -Position profile: N/A (disabled) [can't get system (java.lang.NullPointerException) properties]
    org.lwjgl.LWJGLException: Pixel format not accelerated
    at org.lwjgl.opengl.WindowsPeerInfo.nChoosePixelFormat (Native Method)
    at org.lwjgl.opengl.WindowsPeerInfo.choosePixelFormat(WindowsPeerInfo.java:52)
    at org.lwjgl.opengl.WindowsDisplay.createWindow(WindowsDisplay.java:185)
    at org.lwjgl.opengl.Display.createWindow(Display.java:311)
    at org.lwjgl.opengl.Display.create(Display.java:856)
    at org.lwjgl.opengl.Display.create(Display.java:784)
    at org.lwjgl.opengl.Display.create(Display.java:765)
    at net.minecraft.client.Minecraft.a(SourceFile:233)
    at net.minecraft.client.Minecraft.run(SourceFile:516)
    at java.lang.Thread.run (unknown Source)
    -REPORT of ERROR END bb61788b-

    Hello

    After you reinstall the operating system, you should also go to the website of your computer manufacturer > drivers download section > put your computer model number > search for your operating system and drivers (graphics, audio, etc.) > download and install.

    See you soon.

  • Camileo S20 does not save to the new 16 GB SDHC card

    Camileo s20 won't record I bought a new card 16 GB sdhc for camcorder and it will not save keeps saying memory full, I can record only for 1 min without card
    Any suggestions please?

    You hear it records, but don t want to work with this SDHC 16 GB card, right?
    What is with the other cards? Are you sure that this card is 100% compatible?

    I use SanDisk 4 GB micro SDHC card with adapter with my Camileo H30.

    I think there must be a compatibility problem.

  • Download and save videa clips of DP on PC card

    I have a camcorder with a PYD card. I can plug the camera on PC and watch the clips but when I try and save and store I get the message that says that Windows cannot open them in Media Player. They will not be displayed in the library or any where that I can play the pictures - if I can play the sound. Help please.

    I have a camcorder with a PYD card. I can plug the camera on PC and watch the clips but when I try and save and store I get the message that says that Windows cannot open them in Media Player. They will not be displayed in the library or any where that I can play the pictures - if I can play the sound. Help please.

    ====================================
    What is the brand and model of your camcorder?

    What is a PYD card?

    What is the (extension) format of video clips?

    Looks like the format of your video clips
    not compatible with Windows Media Player.

    You can download and install a more versatile
    Media player, or you can consider converting
    video clips to a more universal format.

    Another option would be to download and install
    a codec Pack.

  • Phones ringtones smart blackBerry on Media card

    I loaded a few rings on my press card.  If I go to 'My Computer' on my PC and view the contents of the map so that plugged into my computer, what ringtones are on the map.  When I pick up the phone to the PC and access the media app tones are not listed.  I can't even to them.  They are on the map, but I can't access it.  Any idea what is the problem?

    After having my battery and a reboot, I can now see the files.  Thanks for the help

  • Cannot run the screen saver because it requires a newer video card or one that is compataible with Direct3D. Hotfix does not work/run

    I am running windows 7 ultimate, 64-bit, SP1

    The screen savers say they can't run, they need a new video card, or a compatible with direct3d.

    I ran the fix.  The issue is pending. Hotfix: KB2159238

    http://support.Microsoft.com/kb/2159238

    All of the video drivers are up to date and they support Direct3D.

    Seems a lot of people have this issue - how to fix? Yet once again, the fix does not work (says "this update is not applicable to your computer")

    Hello Dave,

    Thank you for your response.

    I appreciate your time and your concern.

    It is normal that the fix is made for the Windows 7 version without service pack 1.

    I hope you can try the following methods provided in the previous post.

    However, if the problem persists, I suggest you to uninstall and reinstall display drivers.

    Step 1:
    Uninstall the display driver.

    a. Click Start, type Device Manager in the start search box and press ENTER.
    b. expand 'graphics', right-click on the map and click Uninstall.
    c. restart the computer, if the prompt message.

    Step 2:
    Install the latest driver to display from this link:
    http://66.226.78.22/DownloadSite/drivers/Intel/VGA/VGA (v15.33.31.64.3993) .zip

    For reference:
    http://www.ASRock.com/MB/Intel/B85M-ITX/?cat=download&OS=Win764

    Please keep us updated on the status of the issue.

    Thank you

  • BlackBerry smartphone how to save all my contacts on my Sim Card

    I just bought a new curve and can't find a way to transfer all my contacts on my sim card at the same time.  The gentlemen at the store told me it was possible.

    It is not possible to move all contacts from the SIM card at the same time. You can copy the address book to Blackberry SIM, but not conversely.

  • Save the images imported from an sd card

    I have to do something stupid. I downloaded pictures from a SD card to Lr, but although they appear in recent import I get a window saying file is not found. Image appears in the catalogue and the library, but I'm not (them) in the finder. Maybe another clue, when I do a spotlight for file number search, I get a different picture. I just downloaded Lr who used PSE 14 for several years.

    It is possible that you have imported to a different location that you thought. Have you tried right-clicking on an image and choose the option to display the image in the Finder?

  • BlackBerry Smartphones Can does not remove a ringtone from my phone

    I recently sent and save a ringtone on my phone memory card (8330).  However, I realized that once I saved it, the ring has failed.  When I go in the media, my ringtones, select the ring type and tries to remove it - I get a message that says "File system error" and will not delete the file.

    Is there another way for me to delete it?

    Help, please!

    He worked at JSanders!  Thank you!

  • Satellite in a series - error: conflict of resources - PCI on the card mother BUS: 09

    What started it stops early on with the error:
    -Conflict PCI resources on the card mother BUS: 09, device: 01 function: 00
    -Conflict PCI resources on the card mother BUS: 09, device: 01 function: 02
    -Conflict PCI resources on the card mother BUS: 09, device: 01 function: 03

    I have the option to continue with F! that works.
    I use Windows 8 at the moment, but it seems not so stable. Above mentioned mistakes occurred that after awhile, I upgraded to W8.

    Do I need a new motherboard, or y at - it another option. What does this error mean in normal words.

    Hmm, it looks like a problem with the motherboard or part connected to the motherboard.
    The error indicates this device 01 because of controller 09 conflict
    Have you tested the RAM?

    Recommend doing this! You can use a tool like Memtest or similar.
    Maybe it isn't that a Ram problem and new modules could solve your problem.

  • Toshiba Journe Scan: Cannot save a scanned in the media card image

    I got a scan for Christmas day.
    I can't save a scanned image to the media card, I tried both xd and sd cards.
    I know that they are achievable cards that I took the test photo with them.

    Can someone please help?

    Thanks for the comments dude!

  • How can you save ringtone on external device

    I had to do a factory reset after backing up my data to iTunes. When I've restored everything, my ringtones disappeared. I contacted support and they me regranted the purchase, but I would like to know how to save this ringtone on an external device, so that if I do a restore again, I have my ringtone

    You have it redownloaded on your phone or the computer iTunes? If your phone, then connect to iTunes on your computer and file > devices > transfer purchases, it must copy the ringtones from your computer's iTunes library section (if you it download on your computer, it should already be there); Select ringtones from your computer's iTunes library section; Right-click (command-click on Mac) the tone and select 'Show in Explorer' ('show in finder' on a Mac) and that should take you where it is located on the computer so that you can copy

    By default, your iTunes library is stored in:

    • Mac OS x: /Users/username/Music
    • Windows XP: \Documents and utilisateur\Mes Documents\My Music\ Settings\nom
    • Windows Vista: \Users\username\Music\iTunes
    • Windows 7 and Windows 8: \Users\username\My Music\iTunes

    (I think that Windows 10 is the same as the 7 and 8).

  • Save pictures to SD card

    I didn't find the option to save the pictures taken by the app photo dafault on SD card. How to go?

    a phone that can not save pictures camera directly on the sd card is just stupid. It seems I have to do household work to move them on my sd card to each period.

    sigh

  • Failed to save the UI resource file...

    Hi all

    I have to pass a CVI 6a 2013 CVI.

    After working the binding DLLS/LIBs now everything compiles and links fine and the exe works as expected.

    But there are some users that I have to edit resource files. As soon as I open one of them (a few seconds) or when I want to change one little thing, and then save the file I get the error message next message (see attachment):

    Unable to save the user interface resource file '... uir ' (the file is not a user interface file or damaged)

    What is the problem and how to solve?

    Any idea is welcome.

    Best regards

    Andreas

    Hi all

    Thanks for your ideas.

    I oversaw that effort to push the standard of the button Save of the cvi after I clicked away the strange error messages.

    Strange but true: If the IUR files are saved now (in the appropriate format) and error messages no longer appear.

    I think that there is a small bug (or format or any change...) in 2013 CVI when overtaking of the UIR of CVI 6 files.

    Good day.

    Andreas

  • How can I custom ringtone for each SIM card in acer z630s

    How can I custom my ringtone for each sim card?

    I've tried doing as

    Settings - Sound - ringtone - sim1 (set the ringtone of my default system card SD for each sim)

    Although the rings ringtone as the default value.

    Thanks for the suggesion,

    But after the second time of the system update notification, it works automatically, that I put the ringtone for individual sim card.

    problem has been resolved.

Maybe you are looking for