Summary of multimedia operations in Android

Source: Internet
Author: User

 

1. Multimedia Storage Mechanism:
When the Android system is started, the system automatically scans the sdcard (including large-capacity storage) and system memory multimedia files, and stores the obtained information in two System databases, in the future, if you want to access the information of multimedia files in other programs, they are actually in these two databases, rather than directly accessing sdcard or mobile phone memory. Both databases are located in the/data/com. android. providers. media/databases directory. As shown in:

The name external. db stores sdcard (including media information stored in large capacity) and internal. db stores media information in the mobile phone memory. For example, some ringtones that come with the phone when it leaves the factory. Of course, if multiple sdcards are used for replacement, external. db may not be fixed at this time, but each name does correspond to that sdcard.

You can use the SQLite Expert tool to open this database file for a look:

This is the table that stores the built-in ringtones of the system.

2. Update the multimedia database:
In other programs, if you want to access the information of multimedia files, they are in these two databases, rather than directly accessing sdcard or mobile phone memory. When downloading a song, you may need to update the playlist. Otherwise, you have to restart the machine or unplug the sdcard before inserting it. Currently, there is no other method. All right, if you send a broadcast, the information of the newly downloaded or deleted files will be the same as that of the stepping database.

 

SendBroadcast (new Intent (Intent. ACTION_MEDIA_MOUNTED,

 

Uri. parse ("file: //" + Environment. getExternalStorageDirectory ())));

 

 

3. Available storage path of the program:
In the Android system, there are only two accessible paths, one is sdcard and the other is/data/package name, if you write a file to the/data/package name path, you may not be able to execute the operation after writing the file. Therefore, you must grant the relevant permissions when necessary. You may need to do this:

 

 

/**

*

* Permissions must be granted to newly created files. <BR>

*

* @ Param file: target file

*/

Public void chmod (File file)

{

Try

{

If (null = file)

{

Return;

}

 

String command = "chmod 666" + file. getAbsolutePath ();

Log. I (TAG, "command =" + command );

Runtime runtime = Runtime. getRuntime ();

Runtime.exe c (command );

}

Catch (IOException e)

{

Log. I (TAG, "chmod fail !!!! ");

}

}

From the column of volcano brother

Related Article

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.