Cursor scans local music files, and garbled characters also appear in English names. How can this problem be solved.

Source: Internet
Author: User
Problem description
The code for scanning a local music file and placing it in the list is as follows:
Public list <localmp3> getlistbylocal () {cursor = getcontentresolver (). query (mediastore. audio. media. external_content_uri, null, mediastore. audio. media. default_sort_order); List <localmp3> localmp3s = new arraylist <localmp3> (); For (INT I = 0; I <cursor. getcount (); I ++) {localmp3 localmp3 = new localmp3 (); cursor. movetonext (); String title = cursor. getstring (cursor. getcolumnindex (Medias Tore. audio. media. title); string artist = cursor. getstring (cursor. getcolumnindex (mediastore. audio. media. artist); long duration = cursor. getlong (cursor. getcolumnindex (mediastore. audio. media. duration); string mp3url = cursor. getstring (cursor. getcolumnindex (mediastore. audio. media. data); int ismusic = cursor. getint (cursor. getcolumnindex (mediastore. audio. media. is_music); // determines whether the music is if (ismusic! = 0) {localmp3.settitle (title); localmp3.setartist (artist); localmp3.setduration (duration); localmp3.setmp3url (mp3url); localmp3s. Add (localmp3);} return localmp3s ;}

There is only one music file in the simulator, and the file name is all English,

Test and generate a list in the simulator. all garbled characters with question marks are displayed,

Use a real machine for testing. Some are garbled characters and some can be displayed normally (some Chinese can also be displayed normally ),


How can I solve this garbled problem? I hope you can help me find a solution on the Internet! Solution 1
In the getlistbylocal function, you must execute cursor. Close (). Otherwise, garbled characters may occur (this is related to memory management in cursor ). Solution 2
Do you use a simulator to test whether your English is full-width?

Cursor scans local music files, and garbled characters also appear in English names. How can this problem be solved.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.