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 8329905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:56:57+00:00 2026-06-09T01:56:57+00:00

I am creating one application which record voice and store it in SD card.

  • 0

I am creating one application which record voice and store it in SD card. then i open
this file and want to play or some other option by clicking on that respective file.
But when i click on that list item it’d not playing. I don’t understand where is the problem. Here is my code.

 @Override
public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.listofaudiorecord);
      init_phone_music_grid();
}

private void init_phone_music_grid() {
      System.gc();
      String[] proj = { MediaStore.Audio.Media._ID,
MediaStore.Audio.Media.DATA,
MediaStore.Audio.Media.DISPLAY_NAME,
MediaStore.Video.Media.SIZE };
      musiccursor = managedQuery(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
 proj, null, null, null);
      count = musiccursor.getCount();
      musiclist = (ListView) findViewById(R.id.PhoneMusicList);
      musiclist.setAdapter(new MusicAdapter(getApplicationContext()));

      musiclist.setOnItemClickListener(musicgridlistener);
      mMediaPlayer = new MediaPlayer();
  }

   private OnItemClickListener musicgridlistener = new OnItemClickListener() {
      public void onItemClick(AdapterView parent, View v, int position,
          long id) {
            System.gc();
            music_column_index = musiccursor
        .getColumnIndexOrThrow(MediaStore.Audio.Media.DATA);
            musiccursor.moveToPosition(position);
            String filename = musiccursor.getString(music_column_index);

                  try {
                       if (mMediaPlayer.isPlaying()) {
                            mMediaPlayer.reset();
                       }
                       mMediaPlayer.setDataSource(filename);
                       mMediaPlayer.prepare();
                       mMediaPlayer.start();
                 } catch (Exception e) {

                 }
           }
        };

        public class MusicAdapter extends BaseAdapter {
          private Context mContext;

          public MusicAdapter(Context c) {
                mContext = c;
          }

          public int getCount() {
                return count;
          }

          public Object getItem(int position) {
                return position;
          }

          public long getItemId(int position) {
                return position;
          }

          public View getView(int position, View convertView, ViewGroup parent) {
                System.gc();
                TextView tv = new TextView(mContext.getApplicationContext());
                String id = null;
                if (convertView == null) {
                      music_column_index = musiccursor
.getColumnIndexOrThrow(MediaStore.Audio.Media.DISPLAY_NAME);
                      musiccursor.moveToPosition(position);
                      id = musiccursor.getString(music_column_index);
                      music_column_index = musiccursor
                 .getColumnIndexOrThrow(MediaStore.Audio.Media.SIZE);
                      musiccursor.moveToPosition(position);
                      id += " Size(KB):" + musiccursor.getString(music_column_index);
                      tv.setText(id);
                } else
                      tv = (TextView) convertView;
                return tv;
          }
    }
}  

Please give me any hint.
Thanks in Advance..

  • 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-06-09T01:56:58+00:00Added an answer on June 9, 2026 at 1:56 am

    How about you switch the two

    musiclist.setOnItemClickListener(musicgridlistener);
    mMediaPlayer = new MediaPlayer();
    

    to this

    mMediaPlayer = new MediaPlayer();
    musiclist.setOnItemClickListener(musicgridlistener);
    

    or put the MediaPlayer reference inside the onItemClick()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating one application in which i am using jsp/servlet.. I want to
I'm creating an iPad application which needs a UIPopoverController like this one (I mean,
I am creating one desktop application in which I want to track user activity
I am Creating one application in which I want to set one swf as
I am creating an application for the iPhone which involves having more than one
I am creating one application in .net MVC, in which I am using jQuery
I am creating one sample application in which i am reading database and displaying
I'm creating a PHP Web application, which would involve: 1) Users opening a record
I am creating one application which convert text into speech in Indian English. I
I'm creating a Desktop Java application which needs to store (what could become) reasonably

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.