{"id":892,"date":"2015-07-16T11:19:04","date_gmt":"2015-07-16T03:19:04","guid":{"rendered":"https:\/\/ai.zhousir.top\/?p=892"},"modified":"2026-08-18T12:58:42","modified_gmt":"2026-08-18T04:58:42","slug":"android%e6%96%87%e4%bb%b6%e5%ad%98%e5%82%a8","status":"publish","type":"post","link":"https:\/\/ai.zhousir.top\/?p=892","title":{"rendered":"Android\u6587\u4ef6\u5b58\u50a8"},"content":{"rendered":"<section id=\"wenyan\" style=\"font-family: system-ui, 'Apple Color Emoji', 'Segoe UI', 'Segoe UI Symbol', 'Noto Sans', Roboto, sans-serif; line-height: 1.75; font-size: 16px; color: #000000; caret-color: #000000;\" data-provider=\"WenYan\">\n<blockquote style=\"margin: 20px 0px; display: block; font-size: 0.9em; overflow: auto; border-left: 3px solid #ef7060; color: #6a737d; padding: 10px 10px 10px 20px; background: #fff9f9;\">\n<p style=\"margin: 1em 0px;\">\u7535\u8111\u6587\u4ef6\u5728\u786c\u76d8\u5206\u533a\u4e0a\u3002Android \u5219\u5206\u6210<strong>\u5185\u90e8\u5b58\u50a8 internal<\/strong>\u548c<strong>\u5916\u90e8\u5b58\u50a8 external<\/strong>\u3002\u65e9\u671f\u591a\u6570\u673a\u5668\u5185\u7f6e\u4e0d\u53ef\u5378\u8f7d\u5185\u5b58\uff0c\u518d\u52a0\u4e00\u5f20\u53ef\u5378 SD \u5361\uff1b\u540e\u6765\u4e0d\u5c11\u673a\u578b\u628a\u4e24\u5757\u90fd\u505a\u6210\u5185\u7f6e\u4e0d\u53ef\u5378\uff0c\u4f46\u903b\u8f91\u4e0a\u4ecd\u6309 internal \/ external \u5212\u5206\uff0c\u4e0d\u518d\u7528\u300c\u80fd\u4e0d\u80fd\u62d4\u5361\u300d\u5f53\u6807\u51c6\u3002<\/p>\n<\/blockquote>\n<p><!--more--><\/p>\n<hr>\n<h2 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em; border-bottom: 2px solid #ef7060; display: flex;\"><span style=\"display: inline-block; font-weight: bold; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">\u4e00\u3001\u5185\u90e8\u5b58\u50a8 vs \u5916\u90e8\u5b58\u50a8<\/span><\/h2>\n<table style=\"border-collapse: collapse; margin: 1.4em auto; max-width: 100%; table-layout: fixed; text-align: left; overflow: auto; display: table; overflow-wrap: break-word; word-break: break-all;\" width=\"817\">\n<thead>\n<tr>\n<th style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top; font-weight: bold; background-color: #fff9f9; color: #ef7060;\">\u5bf9\u6bd4<\/th>\n<th style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top; font-weight: bold; background-color: #fff9f9; color: #ef7060;\">Internal<\/th>\n<th style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top; font-weight: bold; background-color: #fff9f9; color: #ef7060;\">External<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u53ef\u7528\u6027<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u603b\u662f\u53ef\u7528<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u4e0d\u4e00\u5b9a\uff0cUSB \u5927\u5bb9\u91cf\u6a21\u5f0f\u65f6\u53ef\u80fd\u8bbf\u95ee\u4e0d\u5230<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u6743\u9650<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u9ed8\u8ba4\u53ea\u6709\u672c app \u80fd\u8bbf\u95ee<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u5927\u5bb6\u90fd\u80fd\u8bbf\u95ee\uff0c\u6ca1\u6709\u8bbf\u95ee\u63a7\u5236<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u5378\u8f7d app<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u76f8\u5173\u6587\u4ef6\u5168\u90e8\u6e05\u6389<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u53ea\u5220 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">getExternalFilesDir()<\/code> \u4e0b\u7684\u79c1\u6709\u6587\u4ef6<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u9002\u5408<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u4e0d\u60f3\u88ab\u7528\u6237\/\u5176\u5b83 app \u78b0\u5230\u7684\u6570\u636e<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u8981\u5171\u4eab\u3001\u6216\u5141\u8bb8\u7528\u7535\u8111\u62f7\u8d70\u7684\u6587\u4ef6<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"margin: 1em 0px;\">Tip\uff1aapp \u9ed8\u8ba4\u88c5\u5230 internal\u3002\u53ef\u5728 manifest \u58f0\u660e <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">android:installLocation<\/code>\uff0c\u5141\u8bb8\u88c5\u5230\u5916\u90e8\u5b58\u50a8\uff08\u5b89\u88c5\u5305\u5f88\u5927\u65f6\u7528\u6237\u66f4\u613f\u610f\u6709\u8fd9\u4e2a\u9009\u9879\uff09\u3002\u8bfb\u5199\u5916\u90e8\u5b58\u50a8\u8981\u6743\u9650\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">&lt;manifest ...&gt;\n    &lt;uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\" \/&gt;\n    &lt;uses-permission android:name=\"android.permission.READ_EXTERNAL_STORAGE\" \/&gt;\n    ...\n&lt;\/manifest&gt;<\/code><\/pre>\n<hr>\n<h2 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em; border-bottom: 2px solid #ef7060; display: flex;\"><span style=\"display: inline-block; font-weight: bold; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">\u4e8c\u3001\u4fdd\u5b58\u5230\u5185\u90e8\u5b58\u50a8<\/span><\/h2>\n<p style=\"margin: 1em 0px;\">\u62ff\u76ee\u5f55\uff1a<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">getFilesDir()<\/code> \u2192 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">\/data\/data\/com.example.android\/files\/<\/code>\uff1b<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">getCacheDir()<\/code> \u2192 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">\/data\/data\/com.example.android\/cache\/<\/code>\u3002<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">File file = new File(getFilesDir(), filename);\n\nFileOutputStream os;\ntry {\n    os = new FileOutputStream(file);\n    os.write(string.getBytes());\n    os.close();\n} catch (FileNotFoundException e) {\n    e.printStackTrace();\n} catch (IOException e) {\n    e.printStackTrace();\n}<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u4e5f\u53ef\u4ee5 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">openFileOutput()<\/code> \u76f4\u63a5\u62ff\u6d41\u5199\u5230 internal\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">String filename = \"myfile\";\nString string = \"Hello world!\";\nFileOutputStream outputStream;\n\ntry {\n  outputStream = openFileOutput(filename, Context.MODE_PRIVATE);\n  outputStream.write(string.getBytes());\n  outputStream.close();\n} catch (Exception e) {\n  e.printStackTrace();\n}<\/code><\/pre>\n<hr>\n<h2 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em; border-bottom: 2px solid #ef7060; display: flex;\"><span style=\"display: inline-block; font-weight: bold; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">\u4e09\u3001\u4fdd\u5b58\u5230\u5916\u90e8\u5b58\u50a8<\/span><\/h2>\n<p style=\"margin: 1em 0px;\">\u8bfb\u5199\u524d\u5148\u68c0\u67e5\u662f\u5426\u53ef\u7528\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">private boolean isExternalStorageWritable() {\n    String state = Environment.getExternalStorageState();\n    if (state.equals(Environment.MEDIA_MOUNTED)) {\n        return true;\n    } else {\n        return false;\n    }\n}<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u5916\u90e8\u518d\u5206<strong>\u516c\u5171\u533a public<\/strong>\u548c<strong>\u79c1\u6709\u533a private<\/strong>\u3002\u516c\u5171\u6587\u4ef6\u5bf9\u7528\u6237\u548c\u5176\u5b83 app \u53ef\u89c1\uff0c\u5378\u8f7d\u672c app \u4e5f\u5e94\u4fdd\u7559\uff08\u62cd\u7167\u3001\u4e0b\u8f7d\uff09\u3002\u79c1\u6709\u6587\u4ef6\u5f52\u672c app\uff0c\u5378\u8f7d\u65f6\u7cfb\u7edf\u4f1a\u5220\u6389 private \u76ee\u5f55\uff08\u4f8b\u5982\u7f13\u5b58\uff09\uff1b\u6280\u672f\u4e0a\u522b\u4eba\u4e5f\u80fd\u8bfb\uff0c\u4f46\u5bf9\u522b\u4eba\u901a\u5e38\u6ca1\u610f\u4e49\u3002<\/p>\n<p style=\"margin: 1em 0px;\">\u516c\u5171\u533a\u7528 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">getExternalStoragePublicDirectory()<\/code>\uff0c\u53c2\u6570\u6307\u5b9a\u7c7b\u578b\uff08\u5982 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">DIRECTORY_MUSIC<\/code>\u3001<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">DIRECTORY_PICTURES<\/code>\uff09\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">public File getPictureStorageDir(String pictureName) {\n    File file = new File(Environment.getExternalStoragePublicDirectory(\n            Environment.DIRECTORY_PICTURES), pictureName);\n    if (!file.mkdirs()) {\n        Log.e(LOG_TAG, \"Directory not created\");\n    }\n    return file;\n}<\/code><\/pre>\n<p style=\"margin: 1em 0px;\"><code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">DIRECTORY_PICTURES<\/code> \u5bf9\u5e94 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">mnt\/sdcard\/Pictures<\/code>\u3002\u5176\u5b83\u6807\u51c6\u76ee\u5f55\uff1a<\/p>\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section>Music\/ \u2014 \u7528\u6237\u97f3\u4e50<\/section>\n<\/li>\n<li>\n<section>Podcasts\/ \u2014 \u97f3\/\u89c6\u9891\u526a\u8f91<\/section>\n<\/li>\n<li>\n<section>Ringtones\/ \u2014 \u94c3\u58f0<\/section>\n<\/li>\n<li>\n<section>Alarms\/ \u2014 \u95f9\u949f<\/section>\n<\/li>\n<li>\n<section>Pictures\/ \u2014 \u56fe\u7247\uff08\u4e0d\u542b\u76f8\u673a\u62cd\u7684\uff09<\/section>\n<\/li>\n<li>\n<section>Movies\/ \u2014 \u7535\u5f71\uff08\u4e0d\u542b\u6444\u50cf\u673a\u62cd\u7684\uff09<\/section>\n<\/li>\n<li>\n<section>Download\/ \u2014 \u5176\u5b83\u4e0b\u8f7d<\/section>\n<\/li>\n<\/ul>\n<p style=\"margin: 1em 0px;\">\u79c1\u6709\u533a\u7528 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">getExternalFilesDir()<\/code>\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">public File getAlbumStorageDir(Context context, String albumName) {\n    File file = new File(context.getExternalFilesDir(\n            Environment.DIRECTORY_PICTURES), albumName);\n    if (!file.mkdirs()) {\n        Log.e(LOG_TAG, \"Directory not created\");\n    }\n    return file;\n}<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u8def\u5f84\u5f62\u5982 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">\/mnt\/sdcard\/Android\/data\/com.example.xx\/files\/Pictures<\/code>\u3002\u4f20 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">null<\/code> \u5219\u8fd4\u56de\u8be5 app \u5916\u90e8\u79c1\u6709\u6839\u76ee\u5f55\u3002<\/p>\n<hr>\n<h2 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em; border-bottom: 2px solid #ef7060; display: flex;\"><span style=\"display: inline-block; font-weight: bold; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">\u56db\u3001\u5b9e\u4f8b\uff1a\u8d44\u6e90\u56fe\u5199\u5165\u516c\u5171\u533a\u518d\u8bfb\u56de<\/span><\/h2>\n<p style=\"margin: 1em 0px;\">\u4ece app \u8bfb\u51fa\u56fe\u7247\u8d44\u6e90\uff0c\u5199\u5165\u5916\u90e8\u516c\u5171\u533a\uff0c\u518d\u8bfb\u6587\u4ef6\u663e\u793a\u5230\u754c\u9762\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">mWriterBtn.setOnClickListener(new OnClickListener() {\n    @Override\n    public void onClick(View v) {\n        if (!isExternalStorageWritable()) {\n            Toast.makeText(MyFileActivity.this, \"\u5916\u90e8\u5b58\u50a8\u4e0d\u53ef\u7528\", Toast.LENGTH_SHORT).show();\n            return;\n        }\n\n        File file = new File(fileDir, PCITRUE_FILE_NAME);\n        FileOutputStream os;\n        try {\n            os = new FileOutputStream(file);\n            Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.m3);\n            bitmap.compress(Bitmap.CompressFormat.PNG, 90, os);\n            os.close();\n        } catch (FileNotFoundException e) {\n            e.printStackTrace();\n        } catch (IOException e) {\n            e.printStackTrace();\n        }\n    }\n});\n\nmReaderBtn.setOnClickListener(new OnClickListener() {\n    @Override\n    public void onClick(View v) {\n        if (!isExternalStorageWritable()) {\n            Toast.makeText(MyFileActivity.this, \"\u5916\u90e8\u5b58\u50a8\u4e0d\u53ef\u7528\", Toast.LENGTH_SHORT).show();\n            return;\n        }\n\n        File file = new File(fileDir, PCITRUE_FILE_NAME);\n        mDirTxt.setText(file.getPath());\n        Bitmap bitmap = BitmapFactory.decodeFile(file.getPath());\n        mShowImg.setImageBitmap(bitmap);\n    }\n});<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u663e\u793a\u6548\u679c<\/p>\n<p style=\"margin: 1em 0px;\"><a href=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2015\/07\/QQ\u255c\u256a\u2550\u255d20150716111647.png\" rel=\"fancybox\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-893\" src=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2015\/07\/QQ\u255c\u256a\u2550\u255d20150716111647.png\" alt=\"QQ\u255c\u256a\u2550\u255d20150716111647\" width=\"208\" height=\"439\" \/><\/a><\/p>\n<blockquote style=\"margin: 20px 0px; display: block; font-size: 0.9em; overflow: auto; border-left: 3px solid #ef7060; color: #6a737d; padding: 10px 10px 10px 20px; background: #fff9f9;\">\n<p style=\"margin: 1em 0px;\"><strong>\u4e00\u53e5\u8bdd\u603b\u7ed3\uff1a\u79c1\u5bc6\u6570\u636e\u653e internal\uff08getFilesDir \/ openFileOutput\uff09\uff1b\u8981\u5171\u4eab\u6216\u7ed9\u7535\u8111\u770b\u7684\u653e external\uff0c\u5148 MEDIA_MOUNTED \u68c0\u67e5\uff0c\u516c\u5171\u76ee\u5f55 getExternalStoragePublicDirectory\uff0c\u79c1\u6709\u76ee\u5f55 getExternalFilesDir\u3002<\/strong><\/p>\n<\/blockquote>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>\u7535\u8111\u6587\u4ef6\u5728\u786c\u76d8\u5206\u533a\u4e0a\u3002Android \u5219\u5206\u6210\u5185\u90e8\u5b58\u50a8 internal\u548c\u5916\u90e8\u5b58\u50a8 external\u3002\u65e9\u671f\u591a\u6570\u673a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[7],"tags":[198],"_links":{"self":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/892"}],"collection":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=892"}],"version-history":[{"count":3,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/892\/revisions"}],"predecessor-version":[{"id":899,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/892\/revisions\/899"}],"wp:attachment":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=892"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=892"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=892"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}