安卓php打开文件夹,Android_Android 文件选择的实现代码,打开文件选择器复制代码 代码 - phpStudy...

Android 文件选择的实现代码

打开文件选择器

private void showFileChooser() {

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);

intent.setType("*/*");

intent.addCategory(Intent.CATEGORY_OPENABLE);

try {

startActivityForResult( Intent.createChooser(intent, "Select a File to Upload"), FILE_SELECT_CODE);

} catch (android.content.ActivityNotFoundException ex) {

Toast.makeText(this, "Please install a File Manager.",  Toast.LENGTH_SHORT).show();

}

}

选择的结果

@Override

protected void onActivityResult(int requestCode, int resultCode, Intent data)  {

switch (requestCode) {

case FILE_SELECT_CODE:

if (resultCode == RESULT_OK) {

// Get the Uri of the selected file

Uri uri = data.getData();

String path = FileUtils.getPath(this, uri);

}

break;

}

super.onActivityResult(requestCode, resultCode, data);

}

FileUtils文件

public class FileUtils {

public static String getPath(Context context, Uri uri) {

if ("content".equalsIgnoreCase(uri.getScheme())) {

String[] projection = { "_data" };

Cursor cursor = null;

try {

cursor = context.getContentResolver().query(uri, projection,null, null, null);

int column_index = cursor.getColumnIndexOrThrow("_data");

if (cursor.moveToFirst()) {

return cursor.getString(column_index);

}

} catch (Exception e) {

// Eat it

}

}

else if ("file".equalsIgnoreCase(uri.getScheme())) {

return uri.getPath();

}

return null;

}

}

这个很简单。

出处:http://www.cnblogs.com/linlf03/相关阅读:

ajax读取数据库内容实现二级联动下拉选择菜单示例

VC实现五子棋游戏的一个算法示例

PHP递归复制、移动目录的自定义函数分享

Win8/8.1系统metro应用中使用IE浏览器出现闪退问题的解决方法

JavaScript子窗口调用父窗口变量和函数的方法

Win10一周年版14393.10更新累积性补丁KB3176929更新内容汇总

查询优化之EXPLAIN的使用分析

解析C#多线程编程中异步多线程的实现及线程池的使用

win10打开compact模式的方法 win10怎么开启compact压缩功能图文教程

采用call方式实现js继承

php获取根域名方法汇总

smarty 缓存控制前的页面静态化原理

基于Javascript实现返回顶部按钮

Windows系统更改开机启动时间三种方法

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
引用和引用提供了关于在phpstudy中安装php扩展的指南。根据这些指南,你可以将php_yaf.dll文件放置在phpstudyPHP路径下,在php.ini文件中手动添加extension=yaf的配置。具体来说,你可以将php_yaf.dll文件复制到D:\phpstudy_pro\Extensions\php\php7.3.4nts\ext路径下,并在php.ini文件中添加extension=yaf配置项。这样就可以在phpstudy的面板中启用yaf扩展了。引用则提供了一个可能导致问题的原因,即项目使用的php版本与cmd的版本不兼容。你可以通过检查项目使用的php版本是否与phpstudy中的版本一致来确认这一点。如果版本不一致,可以在phpstudy中切换php版本或者调整项目的php版本。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [阿里云服务下安装Composer时出现 错误:添加到用户路径:C:/phpStudy/Extensions/php/php7.3.4nts 安装无法...](https://blog.csdn.net/qq_42345116/article/details/122595160)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [php7.3.4可用yaf扩展下载phpstudy小皮面板php_yaf.dll(亲测100%可用)](https://download.csdn.net/download/lingyun820/16593737)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [执行php命令行出现 Failed loading D:\phpStudy\php\php7.3.4nts\ext\php_xdebug.dll](https://blog.csdn.net/weixin_42079053/article/details/105618234)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值