Android-read-only File System

Source: Internet
Author: User

How can I make sdcard have the read and write permissions together?

------------------------------- Other questions -----------------------------
InProgramTo access sdcard, you need to apply for the permission to access sdcard.
The permission to access sdcard in androidmanifest. XML is as follows:
<! -- Create and delete file permissions in sdcard -->
<Uses-Permission Android: Name = "android. Permission. mount_unmount_filesystems"/>
<! -- Write data to sdcard -->
<Uses-Permission Android: Name = "android. Permission. write_external_storage"/>
------------------------------- More about sdcard -------------------------
Why sdcard?
In Android, image downloads on webpages will automatically search for space from sdcard. sdcard is also necessary for development and testing.
1: how to load sdcard in the simulator
This document provides the following examples:
Mksdcard-l sdcard 100 m sdcard. IMG // This will generate an image file of the sdcard in the PC under the tools directory.

Load sdcard when the simulator starts
Emulator-sdcard. IMG-AVD myavd2
In this way, the simulator will be able to see its own sdcard, And you can log on to view it through the ADB shell.

2: traverse sdcard
How can we find some special paths in Android, such as sdcard?
The android. OS. Environment class is very clear, including the following methods:
Getrootdirectory ();
Getdownloadcachedirectory ();

Getexternalstoragedirectory ();

Getexternalstoragestate (); obtains the status of the current sdcard.

Environment. getexternalstoragestate (). Equals (environment. media_mounted) ---- determine whether the sdcard status is available

with the file path, you can use file for various traversal operations.

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.