内部存储在HTC Desire上

| 我正在尝试将文件保存到内部存储(不是SD卡)。正如文档所指出的那样,如果我使用“ 0”,则数据将放在“ 1”之下,但是那里什么也没有。此代码是从这里获取的。不过,类似的代码也适用于Archos。
File path = Environment.getExternalStorageDirectory();
File file = new File(path, \"DemoPicture.jpg\");
txtList.append(file.getPath());

try {
    path.mkdirs();
    InputStream is = getResources().openRawResource(R.drawable.icon);
    OutputStream os = new FileOutputStream(file);
    byte[] data = new byte[is.available()];
    is.read(data);
    os.write(data);
    is.close();
    os.close();
} catch (IOException e) {
    Log.d(\"ExternalStorage\", \"Error writing \" + file, e);
}
我使用的是Android SDK 2.1。清单中已经添加了权限“ 3”。 logcat中没有错误。有什么提示吗?     
已邀请:
您会混淆内部和外部存储。您在谈论内部存储,而实际上您在使用外部存储:
File path = Environment.getExternalStorageDirectory();
生成的文件将位于此处:“ 5”。但是,如果您真的想使用内部存储,请查看
Context.openFileOutput
函数。 编辑: 文件路径= Environment.getExternalStorageDirectory();     文件文件=新文件(路径,\“ DemoPicture.jpg \”);     txtList.append(file.getPath());
try {
    path.mkdirs();
    InputStream is = getResources().openRawResource(R.drawable.icon);
    OutputStream os = new FileOutputStream(file);
    byte[] data = new byte[is.available()];
    is.read(data);
    os.write(data);
    is.close();
    os.close();
} catch (IOException e) {
    Toast.makeText(this, \"Failed to write a file\", Toast.LENGTH_LONG).show();
}
    
忘记更新。 当我只是拔下设备并运行应用程序时,问题就消失了。一位朋友告诉我,他遇到了同样的问题,并关闭了所有可能会访问SD卡的应用,例如Windows资源管理器。     

要回复问题请先登录注册