android 文件公有存储,android:公共目录中的内部存储中保存文件

我试图将图像保存在app文件目录中的公共目录中.通过公开,我的意思是我将能够使用动作视图意图.

/** Saves the bitmap to app storage */

public int SaveBitmap(Bitmap bitmap, String filename, Boolean scan){

// Save the file

OutputStream os = null;

String path = context.getFilesDir() + "/MyAppName/";

File file = new File(path);

if(!file.isDirectory())file.mkdirs();

path += (filename + ".png");

try {

os = new BufferedOutputStream(new FileOutputStream(path,true));

//os = mContext.openFileOutput(, Context.MODE_PRIVATE);

bitmap.compress(CompressFormat.PNG, 100, os);

os.flush();

os.close();

bitmap.recycle();

} catch (IOException e) {

e.printStackTrace();

return 1; //Failure

}

File fileR = new File(path);

fileR.setReadable(true, false);

// Show in Gallery

if(scan) ShowInGallery(filename);

return 0; // SUCCESS

}

这段代码不起作用,文件仍然以私有模式创建.

使用:

context.openFileOutput(filename + ".png", Context.MODE_WORLD_READABLE);

我能够公开打开它们,但我无法将文件保存在该目录中.

请注意,我的目标是没有SD卡的用户,这就是我不使用外部存储的原因.

我能做什么?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值