获得Android系统外置SD卡的路径

方法1:在SD卡中放入特殊文件,搜索此文件找到SD卡http://

JAVA和C实现文件搜索

方法2:

加监听,在加载或者卸载SD时获得SD卡的信息

			public void onReceive(Context context, Intent intent) {
					System.out.println(" Receive SDCard Mount/UnMount!");
					System.out.println( "Data: " + intent.getData());
					DriverName = intent.getData().getPath();//SD卡的路径
					System.out.println( "DriverName: " + DriverName); 
			}

		};
		
		IntentFilter filter = new IntentFilter();
		filter.addAction(Intent.ACTION_MEDIA_MOUNTED);
		filter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
		filter.addDataScheme("file"); 
		registerReceiver(mReceiver, filter);


你可能感兴趣的:(c,android,File,filter)