1. Get the directory of the storage device:/sdcard (generally)
Sdpath = environment. getexternalstoragedirectory () + "/";2. Determine whether the folder on the SD card exists: Use the exists () method of the file object./*** Determine whether a file already exists;*/Public Boolean checkfileexists (string filepath ){File file = new file (sdpath + filepath );Return file. exists ();}3. Create a directory on t
Android implements SD card and memory file storage in the same way. The method for obtaining the file path is basically the same as that of java. The following is the code of the program. The configuration location and implementation are different. Others are the same. The following code is used:
Main. xml:
[Html]Android: orientation = "vertical"Android: layout_width = "fill_parent"Android: layout_height =
Android gets a way to monitor SD card status
The example in this article describes how Android gets to listen for SD card status. Share to everyone for your reference. The specific analysis is as follows:
1. Register Storageeventlistener to monitor the SD
save the image file to the "sdcard/myImage/images" folder named "2017111.jpg"Copy codeThe Code is as follows: File file = new File ("/sdcard/myImage /");File. mkdirs (); // create a folderString fileName = "/sdcard/myImage/111.jpg ";Try {B = new FileOutputStream (fileName );Bitmap. compress (Bitmap. CompressFormat. JPEG, 100, B); // write data to a file} Catch (FileNotFoundException e ){E. printStackTrace ();} Finally {Try {B. flush ();B. close ();} Catch (IOException e ){E. printStackTrace ();
Test procedure]1. Download an application and open the application;2. Press menu to open the management applicationProgramGo to the SD card and click "application" to view the data moved to the SD card and to the mobile phone memory.Expected results]1. The data transferred to the S
1. Use the mksdcard command to create a 128 m sd card image named sdcard. IMG (m must be capitalized.Mksdcard 128 M sdcard. img2. Copy sdcard. IMG to D: \ projects2 and set the startup parameters in the run configuration dialog box in eclipse.-Sdcard D: \ projects2 \ sdcard. imgIn this way, the SD card is available.3.
and output file name based on different mobile phones, so use the code to configure the output path.
2. Android uses Log4j to write logs to the SD card and dynamically modify the name of the output file
1. Use the following code to set the output path and call it in the above init method.
Private static String getOutputPath (Context context, String name) {String rootPath = getSdcardPath (context); StringB
This article illustrates how Android obtains the SD card path and SDcard memory. Share to everyone for your reference. The specific analysis is as follows:
Yesterday in studying the problem of the storage path breakthrough after the photo shoot, the beginning of the storage path is written to death: private String folder = "/sdcard/dcim/camera/" (Image storage path on
Address: http://www.cnblogs.com/TerryBlog/archive/2010/06/26/1765910.html
SD card for Android Simulators
In this example, you can directly specify the music file in the SD card for operations. How can we use the SD card in the and
Read/write SD cardThe Openfileinput and Openfileoutput methods of the context class are file operations for the application's Data folder, which has some limitations due to the limited ROM capacity of the phone.The SD card of the phone provides a larger storage capacity than the ROM. More suitable for accessing large f
Recently, you need to divide the SD card into Several partitions when developing a set-top box gui. The following is a summary of how to partition the SD card.
I. Using the disk management tool fdisk in Linux
Sudo fdisk/dev/SDC
Use fdisk to open your SD
code enables you to save an image file under the "sdcard/myimage/" folder, with the name "111.jpg"
Copy Code code as follows:
File File = new file ("/sdcard/myimage/");
File.mkdirs ();//Create Folder
String fileName = "/sdcard/myimage/111.jpg";
try {
b = new FileOutputStream (fileName);
Bitmap.compress (Bitmap.CompressFormat.JPEG, b);//write data to file
catch (FileNotFoundException e) {
E.printstacktrace ();
finally {
try {
B.flush ();
B.close ();
catch
public static final String DATABASE_NAME = "/mnt/sdcard/demo. db "; // database name public static final String TABLE_NAME =" mytag "; // data table name. A database can contain multiple data tables, similar to Sheet 1 in excel, sheet2 // MyDBHelper constructor. We are concerned with the name DATABASE_NAME and VERSION public MyDBHelper (Context context) {super (context, DATABASE_NAME, null, VERSION );}
Because if it is just a separate file name, The Last database file created is saved on the in
/DEMO.DB"; Database name public
static FINAL String table_name = "mytag";//datasheet name, a database can contain more than one datasheet, similar to the Sheet1,sheet2 in Excel
// Mydbhelper's constructor, we are concerned with the name database_name and version versions public
Mydbhelper {
Super database_name, NULL, VERSION);
Because if just a separate file name, the last created database file is stored in the phone's internal memory card (not
files like your phone's own file system browser.Whether it's an internal SD card or an external SD card, it's a phone's external storage, and the phone's internal storage and external storage share the same device.Internal Storage Path:All apps installed to the phone will generate a package name folder in the Data/dat
https://www.sdcard.org/downloads/formatter_4/eula_mac/Sdformatter mac Edition is an SD card repair tool on Mac OS platform, Sdformatter is a handy SD card format tool, capable of formatting SD memory card and SDHC memory
-B0E6-92A702A99B35 }"; MMC storage class driver[HKEY_LOCAL_MACHINE/Drivers/sdcard/clientdrivers/class/mmc_class]"DLL" = "sdmemory. dll""Prefix" = "DSK""FSD" = "fatfs. dll""IOCTL" = DWORD: 4; disk_ioctl_initialize, sent to driver by devicemanager"Blocktransfersize" = DWORD: 40; send no more than 64 blocks of data per bus transfer; "Singleblockwrites" = DWORD: 1; alternatively force the driver to use single block access"Profile" = "MMC""Iclass" = multi_sz: "{A4E7EDDA-E575-4252-9D6B-4195D48BB865 }"
Code used in this blog: http://download.csdn.net/detail/king_bingge/5739167
I haven't written a blog for several days, and I 've been busy with the opening Cup for the past few days. Due to some inharmonious factors, I started preparing for today's opening Cup reply yesterday. Although I don't know what the result is, however, I personally feel that there are still some innovative ideas, that is, the primary judges and teachers are dragging on to our consumption object and no longer think about
Install a lamp environment for Raspberry Pi in the past two days, but there are too many things installed on it, and the default system space is occupied. But the SD card itself is 16 GB. What if I want to extend the Raspberry Pi to a larger space? I can continue to install the software only after the expansion. After checking the information, linux has a tool, gparted, which can be used to expand and utili
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.