私のアプリケーションは現在、/Pictures/<app_name>/
を指定したフォルダに保存しますが、デフォルトのフォルダ/DCIM/Camera/
に保存します。この結果、ファイルはSDカードに2回保存されますが、異なるフォルダに保存されます。私はそれを両方のフォルダに保存しないように、どうすればいいですか?指定したフォルダだけですか?SDカードに保存されるデフォルトのフォルダを変更するにはどうすればよいですか?
2
A
答えて
2
答えはすでにHereです。
ちょうど私がちょうどリンク先のページが変更された場合、無効な答えを避けるために、ソリューションを追加し、元の答え--->HERE THE SOLUTION
に行きます。
次のコードを確認してください:
private void FillPhotoList() {
// initialize the list!
GalleryList.clear();
String[] projection = { MediaStore.Images.ImageColumns.DISPLAY_NAME };
for(int i=0;i<projection.length;i++)
Log.i("InfoLog","projection "+projection[0].toString());
// intialize the Uri and the Cursor, and the current expected size.
Cursor c = null;
Uri u = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
Log.i("InfoLog","FillPhoto Uri u "+u.toString());
// Query the Uri to get the data path. Only if the Uri is valid.
if (u != null)
{
c = managedQuery(u, projection, null, null, null);
}
// If we found the cursor and found a record in it (we also have the id).
if ((c != null) && (c.moveToFirst()))
{
do
{
// Loop each and add to the list.
GalleryList.add(c.getString(0)); // adding all the images sotred in the mobile phone(Internal and SD card)
}
while (c.moveToNext());
}
Log.i(INFOLOG,"gallery size "+ GalleryList.size());
}
をして、このメソッドは、Androidジンジャーブレッドのバージョン2.3.3のためのすべての魔法
/** Method will check all the photo is the gallery and delete last captured and move it to the required folder.
*/
public void movingCapturedImageFromDCIMtoMerchandising()
{
// This is ##### ridiculous. Some versions of Android save
// to the MediaStore as well. Not sure why! We don't know what
// name Android will give either, so we get to search for this
// manually and remove it.
String[] projection = { MediaStore.Images.ImageColumns.SIZE,
MediaStore.Images.ImageColumns.DISPLAY_NAME,
MediaStore.Images.ImageColumns.DATA,
BaseColumns._ID,};
// intialize the Uri and the Cursor, and the current expected size.
for(int i=0;i<projection.length;i++)
Log.i("InfoLog","on activityresult projection "+projection[i]);
//+" "+projection[1]+" "+projection[2]+" "+projection[3] this will be needed if u remove the for loop
Cursor c = null;
Uri u = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
Log.i("InfoLog","on activityresult Uri u "+u.toString());
if (CurrentFile != null)
{
// Query the Uri to get the data path. Only if the Uri is valid,
// and we had a valid size to be searching for.
if ((u != null) && (CurrentFile.length() > 0))
{
//****u is the place from data will come and projection is the specified data what we want
c = managedQuery(u, projection, null, null, null);
}
// If we found the cursor and found a record in it (we also have the size).
if ((c != null) && (c.moveToFirst()))
{
do
{
// Check each area in the gallery we built before.
boolean bFound = false;
for (String sGallery : GalleryList)
{
if (sGallery.equalsIgnoreCase(c.getString(1)))
{
bFound = true;
Log.i("InfoLog","c.getString(1) "+c.getString(1));
break;
}
}
// To here we looped the full gallery.
if (!bFound) //the file which is newly created and it has to be deleted from the gallery
{
// This is the NEW image. If the size is bigger, copy it.
// Then delete it!
File f = new File(c.getString(2));
// Ensure it's there, check size, and delete!
if ((f.exists()) && (CurrentFile.length() < c.getLong(0)) && (CurrentFile.delete()))
{
// Finally we can stop the copy.
try
{
CurrentFile.createNewFile();
FileChannel source = null;
FileChannel destination = null;
try
{
source = new FileInputStream(f).getChannel();
destination = new FileOutputStream(CurrentFile).getChannel();
destination.transferFrom(source, 0, source.size());
}
finally
{
if (source != null)
{
source.close();
}
if (destination != null)
{
destination.close();
}
}
}
catch (IOException e)
{
// Could not copy the file over.
ToastMaker.makeToast(this, "Error Occured", 0);
}
}
//****deleting the file which is in the gallery
Log.i(INFOLOG,"imagePreORNext1 "+imagePreORNext);
Handler handler = new Handler();
//handler.postDelayed(runnable,300);
Log.i(INFOLOG,"imagePreORNext2 "+imagePreORNext);
ContentResolver cr = getContentResolver();
cr.delete(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, BaseColumns._ID + "=" + c.getString(3), null);
break;
}
}
while (c.moveToNext());
}
}
}
1
を行っている場所を保存場所のカメラのデフォルトを変更することができますです。カメラアプリを起動し、設定(コグ)をクリックし、レンチタブをクリックし、下にスクロールしてメモリカードを選択します。メモリカード(内部メモリ)に変更してください。
関連する問題
- 1. sqliteデータベースをSDカードに保存するにはどうすればよいですか?
- 2. ビデオファイルをSDカードにダウンロードするにはどうすればよいですか?
- 3. SDカードに保存されたビデオをGridViewに表示する
- 4. 外付けSDカードにフォルダを作成するにはどうすればいいですか?
- 5. RxJSに保存されているデータを変更するにはどうすればよいですか?
- 6. ポータブルSDカードをADBコマンドで内蔵ストレージに変換するにはどうすればよいですか?
- 7. SDカードにファイルを保存する
- 8. SDカードに保存された画像を保存するAndroidスタジオ
- 9. WebビューでSDカード内に保存されたhtmlファイルをロードするには
- 10. 自動生成されたファイルの変更を保存するにはどうすればよいですか?
- 11. ByteArrayOutputStreamをSDカードに保存
- 12. SDカードにアンドロイドアプリケーションデータを保存
- 13. imgのsrcをイメージに変換してフォルダに保存するにはどうすればよいですか?
- 14. デフォルトのコントロールテーマを変更するにはどうすればよいですか?
- 15. Androidスタジオのエミュレータで使用するSDカードを作成するにはどうすればよいですか?
- 16. Androidアプリで写真を撮り、写真をギャラリーに内蔵ストレージに保存するにはどうすればよいですか? (SDカードではない)
- 17. Macのデフォルトのフォルダ迷惑メールダウンロードボックスを変更するにはどうすればよいですか?
- 18. Imageresizser - サイズ変更されたイメージをファイルに保存するにはどうすればいいですか?
- 19. FAT16でSDカードをプログラム的にフォーマットするにはどうすればよいですか?
- 20. MS-OfficeドキュメントをSDカードからアンドロイドでプログラムで印刷するにはどうすればよいですか?
- 21. イメージをフォルダから移動し、別のフォルダに保存する前にサイズを変更するにはどうすればよいですか?
- 22. WindowsでSDカードの実際のサイズを取得するにはどうすればよいですか?
- 23. HoneycombでSDカードのディレクトリを取得するにはどうすればよいですか?
- 24. AndroidでリムーバブルSDカードの場所を選択するにはどうすればよいですか?
- 25. 大きなファイルの小さな変更を保存するにはどうすればよいですか?
- 26. memcacheに保存されたデータストア内のデータを更新するにはどうすればよいですか?
- 27. SDカードから選択したビデオを再生するにはどうすればよいですか?
- 28. ビットマップをダウンロードしてメモリを使い果たすことなくSDカードに保存するにはどうすればよいですか?
- 29. OCamlで変数の値を保存して変更するにはどうすればよいですか?
- 30. sdカードから.apkファイルのユーザリストをプログラム的に表示するにはどうすればいいですか?
私は実際にその方法がしようとしているものを得ていませんでした。私はこれを代わりに使用し、それはhttp://stackoverflow.com/questions/8563570/double-save-image – Neeta