혼란 : 질문에 투표를 거절 한 사람들은 몇 가지 의견을 추가 할 수 있습니까? 나는 나쁜 말을하고 싶다. 금지 당하고 싶다.폴더로 파일을 만듭니다
나는 앱을 가지고 있으며 사용자가 물건을 추가하고 앱 안에서 사용할 수 있도록 sdCard에 폴더를 갖고 싶습니다. 내가 폴더를 만들려면 다음 코드를 사용합니다
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//External storage
boolean mExternalStorageAvailable = false;
boolean mExternalStorageWriteable = false;
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state)) {
// We can read and write the media
mExternalStorageAvailable = mExternalStorageWriteable = true;
Log.v("Storage","ablo to read and write");
//create Beatss folder
File direct = new File(android.os.Environment.getExternalStorageDirectory().getPath() + "/Beatss");
Log.v("Storage",android.os.Environment.getExternalStorageDirectory().getPath() + "/Beatss");
boolean success = true;
if (!direct.exists()) {
success = direct.mkdirs();
}
if (success) {
// Do something on success
Log.v("Storage","Folder has been created");
} else {
// Do something else on failure
}
} else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
// We can only read the media
mExternalStorageAvailable = true;
mExternalStorageWriteable = false;
Log.v("Storage","ablo to read only");
} else {
mExternalStorageAvailable = mExternalStorageWriteable = false;
Log.v("Storage","no access");
}
내가 폴더가 생성 된 것을 DDMS에서 볼 수 있지만 내가 WindowsExplorer을 통해 갈 때 내가 대신 폴더의 파일이 있습니다. 폴더를 만드는 방법은?
UPD1 : 그럼에도 불구하고이 폴더 안에 뭔가를 만들었더라도 여전히 Windows 탐색기에 파일로 저장되어 있지만 DDMS에서는 폴더가 있고 다른 폴더에 있음을 알 수 있습니다. 그래서, 여기서 무엇이 잘못 되었습니까 ??
UPD2는 :
01-24 21:14:04.368: V/Storage(12116): /mnt/sdcard/Beatss/
그래서이 ..
UPD3을 : 그래서 실제 경로가 있는지 로그 캣에서 direct
라인을 breaked 나는 그것이 264입니다 내 모든 코드를 보여 질수 지금까지 선. 이 모든 폴더 생성은 mainActivity의 onCreate에서 발생합니다. manifestFile은 다음과 같습니다 : 상단
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="uk.test
android:versionCode="1"
android:versionName="1.0"
android:installLocation="auto" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="16" />
<supports-screens
android:smallScreens= "true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="false"
/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:screenOrientation="portrait"
>
<activity
android:name=".Main"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:clearTaskOnLaunch="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
<activity android:name=".MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait">
</activity>
<activity android:name=".SupportScreen"
android:label="@string/app_name"
android:screenOrientation="portrait">
</activity>
<activity android:name="com.tapjoy.TJCOffersWebView" android:configChanges="keyboardHidden|orientation" />
<activity android:name="com.tapjoy.TapjoyFullScreenAdWebView" android:configChanges="keyboardHidden|orientation" />
<activity android:name="com.tapjoy.TapjoyDailyRewardAdWebView" android:configChanges="keyboardHidden|orientation" />
<activity android:name="com.tapjoy.TapjoyVideoView" android:configChanges="keyboardHidden|orientation" />
</application>
</manifest>
업데이트 코드 :
로그 캣은 말한다 : 여기에있는 응용 프로그램에서 코드 조각의
01-24 21:19:21.068: V/Storage(14088): /mnt/sdcard/Beatss/
01-24 21:19:21.138: V/Storage(14088): Folder has been created
"폴더"안에 파일을 만들거나 나중에 "direct.isDirectory()"를 확인하면 어떻게됩니까? ;) – ConcurrentHashMap
지금까지 시도한 적이 없다 ... 흥미 롭다. – Daler
주의 사항 - sdcard 전체에 12 개의 디렉토리가있는 sdcard를 찾은 사용자를 피하지 말고'/ sdcard/Android/my .pkg.name/.....'최종 사용자가 쉽게 정리할 수 있도록 필요에 따라 ...;) – t0mm13b