Merge "docs: fix syntax error in "Saving Files" document" into nyc-dev
This commit is contained in:
@@ -183,7 +183,7 @@ public File getTempFile(Context context, String url) {
|
||||
try {
|
||||
String fileName = Uri.parse(url).getLastPathSegment();
|
||||
file = File.createTempFile(fileName, null, context.getCacheDir());
|
||||
catch (IOException e) {
|
||||
} catch (IOException e) {
|
||||
// Error while creating file
|
||||
}
|
||||
return file;
|
||||
@@ -250,7 +250,7 @@ public boolean isExternalStorageReadable() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<p>たとえば、自分のアプリでダウンロードした追加のリソースや一時的なメディア ファイルです。</p>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -265,7 +265,7 @@ android.os.Environment#DIRECTORY_PICTURES} などの保存するファイルの
|
||||
|
||||
<pre>
|
||||
public File getAlbumStorageDir(String albumName) {
|
||||
// Get the directory for the user's public pictures directory.
|
||||
// Get the directory for the user's public pictures directory.
|
||||
File file = new File(Environment.getExternalStoragePublicDirectory(
|
||||
Environment.DIRECTORY_PICTURES), albumName);
|
||||
if (!file.mkdirs()) {
|
||||
@@ -287,7 +287,7 @@ android.content.Context#getExternalFilesDir getExternalFilesDir()} を呼び出
|
||||
|
||||
<pre>
|
||||
public File getAlbumStorageDir(Context context, String albumName) {
|
||||
// Get the directory for the app's private pictures directory.
|
||||
// Get the directory for the app's private pictures directory.
|
||||
File file = new File(context.getExternalFilesDir(
|
||||
Environment.DIRECTORY_PICTURES), albumName);
|
||||
if (!file.mkdirs()) {
|
||||
@@ -366,7 +366,7 @@ myContext.deleteFile(fileName);
|
||||
|
||||
<div class="note">
|
||||
<p><strong>注:</strong> ユーザーがアプリをアンインストールすると、Android システムは次を削除します。
|
||||
</p>
|
||||
</p>
|
||||
<ul>
|
||||
<li>内部ストレージに保存したすべてのファイル</li>
|
||||
<li>{@link
|
||||
|
||||
@@ -183,7 +183,7 @@ public File getTempFile(Context context, String url) {
|
||||
try {
|
||||
String fileName = Uri.parse(url).getLastPathSegment();
|
||||
file = File.createTempFile(fileName, null, context.getCacheDir());
|
||||
catch (IOException e) {
|
||||
} catch (IOException e) {
|
||||
// Error while creating file
|
||||
}
|
||||
return file;
|
||||
@@ -250,7 +250,7 @@ public boolean isExternalStorageReadable() {
|
||||
앱을 제거하면 같이 삭제됩니다. 이러한 파일은
|
||||
엄밀히 말해 외부 저장소에 저장된 파일이기 때문에 사용자 및 다른 앱의 액세스가 가능하긴 하지만, 앱 외부에서
|
||||
사용자에게 값을 실제로 제공하지는 않습니다. 사용자가 앱을 제거하면 앱의 외부 개인 디렉터리 내 모든 파일을 시스템에서
|
||||
삭제합니다.
|
||||
삭제합니다.
|
||||
<p>예를 들어 앱에서 다운로드한 추가 리소스 또는 임시 미디어 파일이 이에 해당합니다.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -265,7 +265,7 @@ android.os.Environment#DIRECTORY_PICTURES}와 같은 다른 공개
|
||||
|
||||
<pre>
|
||||
public File getAlbumStorageDir(String albumName) {
|
||||
// Get the directory for the user's public pictures directory.
|
||||
// Get the directory for the user's public pictures directory.
|
||||
File file = new File(Environment.getExternalStoragePublicDirectory(
|
||||
Environment.DIRECTORY_PICTURES), albumName);
|
||||
if (!file.mkdirs()) {
|
||||
@@ -287,7 +287,7 @@ android.content.Context#getExternalFilesDir getExternalFilesDir()}을 호출하
|
||||
|
||||
<pre>
|
||||
public File getAlbumStorageDir(Context context, String albumName) {
|
||||
// Get the directory for the app's private pictures directory.
|
||||
// Get the directory for the app's private pictures directory.
|
||||
File file = new File(context.getExternalFilesDir(
|
||||
Environment.DIRECTORY_PICTURES), albumName);
|
||||
if (!file.mkdirs()) {
|
||||
@@ -357,7 +357,7 @@ JPEG로 변환하여 파일 인코딩을
|
||||
myFile.delete();
|
||||
</pre>
|
||||
|
||||
<p>파일이 내부 저장소에 저장되어 있는 경우, {@link android.content.Context}에 위치를 요청하고 {@link android.content.Context#deleteFile deleteFile()}을 호출하여 파일을
|
||||
<p>파일이 내부 저장소에 저장되어 있는 경우, {@link android.content.Context}에 위치를 요청하고 {@link android.content.Context#deleteFile deleteFile()}을 호출하여 파일을
|
||||
삭제할 수도 있습니다.</p>
|
||||
|
||||
<pre>
|
||||
@@ -366,7 +366,7 @@ myContext.deleteFile(fileName);
|
||||
|
||||
<div class="note">
|
||||
<p><strong>참고:</strong> 사용자가 앱을 제거하면 Android 시스템이
|
||||
다음 항목을 삭제합니다.</p>
|
||||
다음 항목을 삭제합니다.</p>
|
||||
<ul>
|
||||
<li>내부 저장소에 저장한 모든 파일</li>
|
||||
<li>{@link
|
||||
|
||||
@@ -183,7 +183,7 @@ public File getTempFile(Context context, String url) {
|
||||
try {
|
||||
String fileName = Uri.parse(url).getLastPathSegment();
|
||||
file = File.createTempFile(fileName, null, context.getCacheDir());
|
||||
catch (IOException e) {
|
||||
} catch (IOException e) {
|
||||
// Error while creating file
|
||||
}
|
||||
return file;
|
||||
@@ -250,12 +250,12 @@ o usuário deve continuar a ter acesso a esses arquivos.
|
||||
. Embora esses arquivos estejam teoricamente à disposição do usuário e de outros aplicativo por estarem
|
||||
no armazenamento externo, na verdade são arquivos que não têm valor para o usuário
|
||||
fora do aplicativo. Ao desinstalar o aplicativo, o sistema exclui
|
||||
todos os arquivos no diretório privado externo do aplicativo.
|
||||
todos os arquivos no diretório privado externo do aplicativo.
|
||||
<p>Por exemplo, recursos adicionais baixados através do aplicativo ou arquivos de mídia temporários.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<p>Para salvar arquivos públicos no armazenamento externo, use o método
|
||||
<p>Para salvar arquivos públicos no armazenamento externo, use o método
|
||||
{@link android.os.Environment#getExternalStoragePublicDirectory
|
||||
getExternalStoragePublicDirectory()} para obter um {@link java.io.File} que representa
|
||||
o diretório correto no armazenamento externo. O método exige um argumento que especifica
|
||||
@@ -265,7 +265,7 @@ android.os.Environment#DIRECTORY_PICTURES}. Por exemplo:</p>
|
||||
|
||||
<pre>
|
||||
public File getAlbumStorageDir(String albumName) {
|
||||
// Get the directory for the user's public pictures directory.
|
||||
// Get the directory for the user's public pictures directory.
|
||||
File file = new File(Environment.getExternalStoragePublicDirectory(
|
||||
Environment.DIRECTORY_PICTURES), albumName);
|
||||
if (!file.mkdirs()) {
|
||||
@@ -287,7 +287,7 @@ usuário faz a desinstalação.</p>
|
||||
|
||||
<pre>
|
||||
public File getAlbumStorageDir(Context context, String albumName) {
|
||||
// Get the directory for the app's private pictures directory.
|
||||
// Get the directory for the app's private pictures directory.
|
||||
File file = new File(context.getExternalFilesDir(
|
||||
Environment.DIRECTORY_PICTURES), albumName);
|
||||
if (!file.mkdirs()) {
|
||||
@@ -366,7 +366,7 @@ myContext.deleteFile(fileName);
|
||||
|
||||
<div class="note">
|
||||
<p><strong>Observação:</strong> quando o usuário desinstala o aplicativo, o sistema Android também
|
||||
exclui:</p>
|
||||
exclui:</p>
|
||||
<ul>
|
||||
<li>Todos os arquivos salvos no armazenamento interno</li>
|
||||
<li>Todos os arquivos salvos no armazenamento externo usando {@link
|
||||
|
||||
@@ -183,7 +183,7 @@ public File getTempFile(Context context, String url) {
|
||||
try {
|
||||
String fileName = Uri.parse(url).getLastPathSegment();
|
||||
file = File.createTempFile(fileName, null, context.getCacheDir());
|
||||
catch (IOException e) {
|
||||
} catch (IOException e) {
|
||||
// Error while creating file
|
||||
}
|
||||
return file;
|
||||
@@ -250,7 +250,7 @@ public boolean isExternalStorageReadable() {
|
||||
вашего приложения пользователем. Хотя технически эти файлы доступны для пользователя и других приложений, поскольку находятся
|
||||
во внешнем хранилище, они не имеют никакой ценности для пользователей
|
||||
вне вашего приложения. Когда пользователь удаляет ваше приложение, система удаляет
|
||||
все файлы из каталога закрытых файлов вашего приложения во внешнем хранилище.
|
||||
все файлы из каталога закрытых файлов вашего приложения во внешнем хранилище.
|
||||
<p>Например, к этой категории относятся дополнительные ресурсы, загруженные приложением, и временные мультимедийные файлы.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -265,7 +265,7 @@ android.os.Environment#DIRECTORY_PICTURES}. Например:</p>
|
||||
|
||||
<pre>
|
||||
public File getAlbumStorageDir(String albumName) {
|
||||
// Get the directory for the user's public pictures directory.
|
||||
// Get the directory for the user's public pictures directory.
|
||||
File file = new File(Environment.getExternalStoragePublicDirectory(
|
||||
Environment.DIRECTORY_PICTURES), albumName);
|
||||
if (!file.mkdirs()) {
|
||||
@@ -287,7 +287,7 @@ android.content.Context#getExternalFilesDir getExternalFilesDir()} и предо
|
||||
|
||||
<pre>
|
||||
public File getAlbumStorageDir(Context context, String albumName) {
|
||||
// Get the directory for the app's private pictures directory.
|
||||
// Get the directory for the app's private pictures directory.
|
||||
File file = new File(context.getExternalFilesDir(
|
||||
Environment.DIRECTORY_PICTURES), albumName);
|
||||
if (!file.mkdirs()) {
|
||||
@@ -332,7 +332,7 @@ java.io.File#getTotalSpace}. Эти методы позволяют узнать
|
||||
общее пространство в хранилище. Эта информация также позволять
|
||||
избежать переполнения объема хранилища сверх определенного уровня.</p>
|
||||
|
||||
<p>Однако система не гарантирует возможность записи такого же количества байт, как указано
|
||||
<p>Однако система не гарантирует возможность записи такого же количества байт, как указано
|
||||
в {@link java.io.File#getFreeSpace}. Если выводимое число на
|
||||
несколько мегабайт превышает размер данных, которые вы хотите сохранить, или если файловая система заполнена
|
||||
менее, чем на 90%, дальше можно действовать спокойно.
|
||||
@@ -366,13 +366,13 @@ myContext.deleteFile(fileName);
|
||||
|
||||
<div class="note">
|
||||
<p><strong>Примечание.</strong> При удалении пользователем вашего приложения система Android удаляет
|
||||
следующие элементы:</p>
|
||||
следующие элементы:</p>
|
||||
<ul>
|
||||
<li>Все файлы, сохраненные во внутреннем хранилище</li>
|
||||
<li>Все файлы, сохраненные во внешнем хранилище с использованием {@link
|
||||
android.content.Context#getExternalFilesDir getExternalFilesDir()}.</li>
|
||||
</ul>
|
||||
<p>Однако вам следует регулярно вручную очищать кэш-память, чтобы удалить файлы, созданные с помощью
|
||||
<p>Однако вам следует регулярно вручную очищать кэш-память, чтобы удалить файлы, созданные с помощью
|
||||
{@link android.content.Context#getCacheDir()}, а также удалять любые
|
||||
другие ненужные файлы.</p>
|
||||
</div>
|
||||
|
||||
@@ -183,7 +183,7 @@ public File getTempFile(Context context, String url) {
|
||||
try {
|
||||
String fileName = Uri.parse(url).getLastPathSegment();
|
||||
file = File.createTempFile(fileName, null, context.getCacheDir());
|
||||
catch (IOException e) {
|
||||
} catch (IOException e) {
|
||||
// Error while creating file
|
||||
}
|
||||
return file;
|
||||
@@ -250,7 +250,7 @@ public boolean isExternalStorageReadable() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<p>例如,您的应用下载的其他资源或临时介质文件。</p>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -265,7 +265,7 @@ android.os.Environment#DIRECTORY_PICTURES}。
|
||||
|
||||
<pre>
|
||||
public File getAlbumStorageDir(String albumName) {
|
||||
// Get the directory for the user's public pictures directory.
|
||||
// Get the directory for the user's public pictures directory.
|
||||
File file = new File(Environment.getExternalStoragePublicDirectory(
|
||||
Environment.DIRECTORY_PICTURES), albumName);
|
||||
if (!file.mkdirs()) {
|
||||
@@ -287,7 +287,7 @@ android.content.Context#getExternalFilesDir getExternalFilesDir()} 获取相应
|
||||
|
||||
<pre>
|
||||
public File getAlbumStorageDir(Context context, String albumName) {
|
||||
// Get the directory for the app's private pictures directory.
|
||||
// Get the directory for the app's private pictures directory.
|
||||
File file = new File(context.getExternalFilesDir(
|
||||
Environment.DIRECTORY_PICTURES), albumName);
|
||||
if (!file.mkdirs()) {
|
||||
@@ -311,7 +311,7 @@ getExternalStoragePublicDirectory()}。
|
||||
|
||||
<p>无论您对于共享的文件使用 {@link
|
||||
android.os.Environment#getExternalStoragePublicDirectory
|
||||
getExternalStoragePublicDirectory()} 还是对您的应用专用文件使用
|
||||
getExternalStoragePublicDirectory()} 还是对您的应用专用文件使用
|
||||
{@link android.content.Context#getExternalFilesDir
|
||||
getExternalFilesDir()} ,您使用诸如
|
||||
{@link android.os.Environment#DIRECTORY_PICTURES} 的 API 常数提供的目录名称非常重要。
|
||||
@@ -332,7 +332,7 @@ java.io.IOException} 。
|
||||
此信息也可用来避免填充存储卷以致超出特定阈值。
|
||||
</p>
|
||||
|
||||
<p>但是,系统并不保证您可以写入与 {@link java.io.File#getFreeSpace}
|
||||
<p>但是,系统并不保证您可以写入与 {@link java.io.File#getFreeSpace}
|
||||
指示的一样多的字节。如果返回的数字比您要保存的数据大小大出几 MB,或如果文件系统所占空间不到 90%,则可安全继续操作。否则,您可能不应写入存储。
|
||||
|
||||
|
||||
@@ -366,7 +366,7 @@ myContext.deleteFile(fileName);
|
||||
|
||||
<div class="note">
|
||||
<p><strong>注意:</strong>当用户卸载您的应用时,Android 系统会删除以下各项:
|
||||
</p>
|
||||
</p>
|
||||
<ul>
|
||||
<li>您保存在内部存储中的所有文件</li>
|
||||
<li>您使用 {@link
|
||||
|
||||
@@ -40,7 +40,7 @@ API 讀取並寫入檔案。
|
||||
該物件的用途很廣,例如非常適用於影像檔案或透過網路交換的項目。
|
||||
</p>
|
||||
|
||||
<p>本課程將顯示如何在您的應用程式中執行與檔案相關的基本任務。本課程假設您已熟悉 Linux 檔案系統的基本概念,以及
|
||||
<p>本課程將顯示如何在您的應用程式中執行與檔案相關的基本任務。本課程假設您已熟悉 Linux 檔案系統的基本概念,以及
|
||||
{@link java.io} 中的標準檔案輸入/輸出 API。
|
||||
</p>
|
||||
|
||||
@@ -183,7 +183,7 @@ public File getTempFile(Context context, String url) {
|
||||
try {
|
||||
String fileName = Uri.parse(url).getLastPathSegment();
|
||||
file = File.createTempFile(fileName, null, context.getCacheDir());
|
||||
catch (IOException e) {
|
||||
} catch (IOException e) {
|
||||
// Error while creating file
|
||||
}
|
||||
return file;
|
||||
@@ -250,12 +250,12 @@ public boolean isExternalStorageReadable() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<p>例如,您的應用程式下載的附加資源,或暫存媒體檔案都是私用檔案。</p>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<p>若您希望將公用檔案儲存在外部儲存空間,請使用
|
||||
<p>若您希望將公用檔案儲存在外部儲存空間,請使用
|
||||
{@link android.os.Environment#getExternalStoragePublicDirectory
|
||||
getExternalStoragePublicDirectory()} 方法取得代表外部儲存空間內相應目錄的 {@link java.io.File}。
|
||||
該方法採用對要儲存的檔案類型進行指定 (以便能合理區分這些檔案與其他公用檔案) 的引數,諸如 {@link android.os.Environment#DIRECTORY_MUSIC} 或 {@link
|
||||
@@ -265,7 +265,7 @@ android.os.Environment#DIRECTORY_PICTURES}。
|
||||
|
||||
<pre>
|
||||
public File getAlbumStorageDir(String albumName) {
|
||||
// Get the directory for the user's public pictures directory.
|
||||
// Get the directory for the user's public pictures directory.
|
||||
File file = new File(Environment.getExternalStoragePublicDirectory(
|
||||
Environment.DIRECTORY_PICTURES), albumName);
|
||||
if (!file.mkdirs()) {
|
||||
@@ -287,7 +287,7 @@ android.content.Context#getExternalFilesDir getExternalFilesDir()},然後向
|
||||
|
||||
<pre>
|
||||
public File getAlbumStorageDir(Context context, String albumName) {
|
||||
// Get the directory for the app's private pictures directory.
|
||||
// Get the directory for the app's private pictures directory.
|
||||
File file = new File(context.getExternalFilesDir(
|
||||
Environment.DIRECTORY_PICTURES), albumName);
|
||||
if (!file.mkdirs()) {
|
||||
@@ -366,7 +366,7 @@ myContext.deleteFile(fileName);
|
||||
|
||||
<div class="note">
|
||||
<p><strong>注意:</strong>使用者解除安裝您的應用程式時,Android 系統會刪除以下檔案:
|
||||
</p>
|
||||
</p>
|
||||
<ul>
|
||||
<li>您在內部儲存空間儲存的所有檔案</li>
|
||||
<li>您使用 {@link
|
||||
|
||||
@@ -192,7 +192,7 @@ public File getTempFile(Context context, String url) {
|
||||
try {
|
||||
String fileName = Uri.parse(url).getLastPathSegment();
|
||||
file = File.createTempFile(fileName, null, context.getCacheDir());
|
||||
catch (IOException e) {
|
||||
} catch (IOException e) {
|
||||
// Error while creating file
|
||||
}
|
||||
return file;
|
||||
@@ -259,7 +259,7 @@ these files should remain available to the user.
|
||||
your app. Although these files are technically accessible by the user and other apps because they
|
||||
are on the external storage, they are files that realistically don't provide value to the user
|
||||
outside your app. When the user uninstalls your app, the system deletes
|
||||
all files in your app's external private directory.
|
||||
all files in your app's external private directory.
|
||||
<p>For example, additional resources downloaded by your app or temporary media files.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -274,7 +274,7 @@ android.os.Environment#DIRECTORY_PICTURES}. For example:</p>
|
||||
|
||||
<pre>
|
||||
public File getAlbumStorageDir(String albumName) {
|
||||
// Get the directory for the user's public pictures directory.
|
||||
// Get the directory for the user's public pictures directory.
|
||||
File file = new File(Environment.getExternalStoragePublicDirectory(
|
||||
Environment.DIRECTORY_PICTURES), albumName);
|
||||
if (!file.mkdirs()) {
|
||||
@@ -296,7 +296,7 @@ user uninstalls your app.</p>
|
||||
|
||||
<pre>
|
||||
public File getAlbumStorageDir(Context context, String albumName) {
|
||||
// Get the directory for the app's private pictures directory.
|
||||
// Get the directory for the app's private pictures directory.
|
||||
File file = new File(context.getExternalFilesDir(
|
||||
Environment.DIRECTORY_PICTURES), albumName);
|
||||
if (!file.mkdirs()) {
|
||||
@@ -375,7 +375,7 @@ myContext.deleteFile(fileName);
|
||||
|
||||
<div class="note">
|
||||
<p><strong>Note:</strong> When the user uninstalls your app, the Android system deletes
|
||||
the following:</p>
|
||||
the following:</p>
|
||||
<ul>
|
||||
<li>All files you saved on internal storage</li>
|
||||
<li>All files you saved on external storage using {@link
|
||||
|
||||
Reference in New Issue
Block a user