• <legend id='jPTor'><style id='jPTor'><dir id='jPTor'><q id='jPTor'></q></dir></style></legend>

    <i id='jPTor'><tr id='jPTor'><dt id='jPTor'><q id='jPTor'><span id='jPTor'><b id='jPTor'><form id='jPTor'><ins id='jPTor'></ins><ul id='jPTor'></ul><sub id='jPTor'></sub></form><legend id='jPTor'></legend><bdo id='jPTor'><pre id='jPTor'><center id='jPTor'></center></pre></bdo></b><th id='jPTor'></th></span></q></dt></tr></i><div id='jPTor'><tfoot id='jPTor'></tfoot><dl id='jPTor'><fieldset id='jPTor'></fieldset></dl></div>
      <tfoot id='jPTor'></tfoot>

          <bdo id='jPTor'></bdo><ul id='jPTor'></ul>

        <small id='jPTor'></small><noframes id='jPTor'>

      1. Android将图像从图库文件夹复制到SD卡替代文件夹

        Android copy image from gallery folder onto SD Card alternative folder(Android将图像从图库文件夹复制到SD卡替代文件夹)

          <tbody id='D5hTC'></tbody>

          <legend id='D5hTC'><style id='D5hTC'><dir id='D5hTC'><q id='D5hTC'></q></dir></style></legend>
            <bdo id='D5hTC'></bdo><ul id='D5hTC'></ul>
          • <i id='D5hTC'><tr id='D5hTC'><dt id='D5hTC'><q id='D5hTC'><span id='D5hTC'><b id='D5hTC'><form id='D5hTC'><ins id='D5hTC'></ins><ul id='D5hTC'></ul><sub id='D5hTC'></sub></form><legend id='D5hTC'></legend><bdo id='D5hTC'><pre id='D5hTC'><center id='D5hTC'></center></pre></bdo></b><th id='D5hTC'></th></span></q></dt></tr></i><div id='D5hTC'><tfoot id='D5hTC'></tfoot><dl id='D5hTC'><fieldset id='D5hTC'></fieldset></dl></div>
                <tfoot id='D5hTC'></tfoot>

                <small id='D5hTC'></small><noframes id='D5hTC'>

                  本文介绍了Android将图像从图库文件夹复制到SD卡替代文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在寻找某人来协助我在我的应用程序中所需的代码,以将图像从它们存储在 HTC 愿望作为标准(画廊)的位置复制到 SD 卡上的另一个文件夹.我希望用户能够单击一个按钮并将某个文件从 SD 卡库文件夹复制到 SD 卡上的另一个文件夹?谢谢

                  I am looking for someone to assist in the code i require in my application to copya image from where they get stored on the HTC desire as standard(the gallery) to a another folder on the SD card. I want the user to be able to click on a button and a certain file is copied from the SD card gallery folder to the another folder on the SD card? Thanks

                  推荐答案

                  Usmaan,

                  您可以通过以下方式启动图库选择器意图:

                  You can launch the gallery picker intent with the following:

                      public void imageFromGallery() {
                      Intent getImageFromGalleryIntent = 
                        new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.INTERNAL_CONTENT_URI);
                      startActivityForResult(getImageFromGalleryIntent, SELECT_IMAGE);
                  }
                  

                  返回时,通过以下部分代码获取选中图片的路径:

                  When it returns, get the path of the selected image with the following portion of code:

                  public void onActivityResult(int requestCode, int resultCode, Intent data) {
                      super.onActivityResult(requestCode, resultCode, data);
                      if (resultCode == RESULT_OK) {
                          switch(requestCode) {
                          case SELECT_IMAGE:
                              mSelectedImagePath = getPath(data.getData());
                              break;
                      }
                  }
                  
                  public String getPath(Uri uri) {
                      String[] projection = { MediaStore.Images.Media.DATA };
                      Cursor cursor = managedQuery(uri, projection, null, null, null);
                      startManagingCursor(cursor);
                      int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
                      cursor.moveToFirst();
                      return cursor.getString(column_index);
                  }
                  

                  现在您已将路径名包含在字符串中,您可以将其复制到另一个位置.

                  Now that you have the pathname in a string you can copy it to another location.

                  干杯!

                  如果您只需要复制文件,请尝试...

                  If you just need to copy a file try something like...

                  try {
                      File sd = Environment.getExternalStorageDirectory();
                      File data = Environment.getDataDirectory();
                      if (sd.canWrite()) {
                          String sourceImagePath= "/path/to/source/file.jpg";
                          String destinationImagePath= "/path/to/destination/file.jpg";
                          File source= new File(data, sourceImagePath);
                          File destination= new File(sd, destinationImagePath);
                          if (source.exists()) {
                              FileChannel src = new FileInputStream(source).getChannel();
                              FileChannel dst = new FileOutputStream(destination).getChannel();
                              dst.transferFrom(src, 0, src.size());
                              src.close();
                              dst.close();
                          }
                      }
                  } catch (Exception e) {}
                  

                  这篇关于Android将图像从图库文件夹复制到SD卡替代文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  what#39;s property copy means in Cocoa#39;s Framework?(like UITabBar#39;s items property)(Cocoa 框架中的属性副本是什么意思?(如 UITabBar 的 items 属性))
                  Sqlite database not copied from asset folder Android(Sqlite 数据库未从资产文件夹 Android 复制)
                  SQLite Database Copy Appears Corrupted When Generated by Device and not Emulator(SQLite 数据库副本在由设备而不是模拟器生成时出现损坏)
                  WebKit on th iPhone: is it possible to copy text to the clipboad with JavaScript(iPhone上的WebKit:是否可以使用JavaScript将文本复制到剪贴板)
                  Difference between retain and copy?(保留和复制的区别?)
                  Can`t copy file from bundle to documents directory in iOS(无法将文件从捆绑包复制到 iOS 中的文档目录)
                  • <tfoot id='uT3rZ'></tfoot>
                    <legend id='uT3rZ'><style id='uT3rZ'><dir id='uT3rZ'><q id='uT3rZ'></q></dir></style></legend>
                  • <small id='uT3rZ'></small><noframes id='uT3rZ'>

                  • <i id='uT3rZ'><tr id='uT3rZ'><dt id='uT3rZ'><q id='uT3rZ'><span id='uT3rZ'><b id='uT3rZ'><form id='uT3rZ'><ins id='uT3rZ'></ins><ul id='uT3rZ'></ul><sub id='uT3rZ'></sub></form><legend id='uT3rZ'></legend><bdo id='uT3rZ'><pre id='uT3rZ'><center id='uT3rZ'></center></pre></bdo></b><th id='uT3rZ'></th></span></q></dt></tr></i><div id='uT3rZ'><tfoot id='uT3rZ'></tfoot><dl id='uT3rZ'><fieldset id='uT3rZ'></fieldset></dl></div>

                            <bdo id='uT3rZ'></bdo><ul id='uT3rZ'></ul>
                              <tbody id='uT3rZ'></tbody>