Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3603490
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:52:43+00:00 2026-05-18T20:52:43+00:00

my problem is a little bit tricky to describe. I have a separated resources

  • 0

my problem is a little bit tricky to describe.

I have a separated resources folder in my project (and in the apk-file).

String path = "/resources/instruments/data/bongo/audio/bong1.wav";  

I can already use it with

url = StreamHelper.class.getClassLoader().getResource( path );
url.openStream();

but actually I want to load the file into the SoundPool.
I tried it this way:

SoundPool soundPool = new SoundPool(  5, AudioManager.STREAM_MUSIC, 0 );  
soundPool.load ( path, 1 );

… but i always get an error information: “error loading /resourc…”

load(String path, int )
On this link I’ve seen that I need the correct path for File

File file = new File( path );
if( file.exists() ) 
     //always false but i thing if it would be true soundPool.load should work too

Now my question: how has the path to be that it works. Or is there any other idea for my problem (p.e. with the AssetManager) ?

Btw. I know that there are special Android ways to get resources like R.id.View … but in my case it would be not easy to handle.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T20:52:44+00:00Added an answer on May 18, 2026 at 8:52 pm

    Personally, I don’t see WAV files as ‘resources’ and I’d suggest you put them in the ‘assets’ folder and use AssetManager as you mentioned.

    This works for me…

    Create a folder structure in your project…

        /assets/instruments/data/bongo/audio
    

    …then copy your bong1.wav file there.

    Use the following to load it. NOTE: DO NOT put ‘/’ in front of ‘instruments’ when supplying the path to soundPool.load()…

        // Declare globally if needed
        int mySoundId;
        SoundPool soundPool = new SoundPool(5, AudioManager.STREAM_MUSIC, 0 );
        AssetManager am = this.getAssets();
    
        //Use in whatever method is used to load the sounds
        try {
            mySoundId = soundPool.load(am.openFd("instruments/data/bongo/audio/bong1.wav"), 1);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    

    Use this to play it…

        soundPool.play(mySoundId, 1, 1, 0, 0, 1);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have a little bit of a problem. I working on a project
My problem is a little bit hard but simple. I have (or there is)
This little bit of code will help me describe my problem: public class Car
My problem is a little bit complex. I have the following code: $(document).ready(function() {
I have a little bit problem with resizing Listview control. I intend to make
This is a little bit of weird problem here. Say I have a C++
I have to to game for my school project. I have a little problem
i have little bit of problem while working with External entity reference in External
im having small problem within my file creator class . im a little bit
So I'll describe a little bit problem - 1) I got PayPal IPN script,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.