Android 项目图像显示在图库中
我仍在开发我的第一个应用程序。我的问题是,我的所有图像都显示在图库中。如何防止这种情况发生?您应该像这样将图像保存在内部位置Android 项目图像显示在图库中,android,image,hide,gallery,Android,Image,Hide,Gallery,我仍在开发我的第一个应用程序。我的问题是,我的所有图像都显示在图库中。如何防止这种情况发生?您应该像这样将图像保存在内部位置 private String saveToInternalSorage(Bitmap bitmapImage){ ContextWrapper cw = new ContextWrapper(getApplicationContext()); // path to /data/data/yourapp/app_data/imageDir File
private String saveToInternalSorage(Bitmap bitmapImage){
ContextWrapper cw = new ContextWrapper(getApplicationContext());
// path to /data/data/yourapp/app_data/imageDir
File directory = cw.getDir("imageDir", Context.MODE_PRIVATE);
// Create imageDir
File mypath=new File(directory,"profile.jpg");
FileOutputStream fos = null;
try {
fos = new FileOutputStream(mypath);
// Use the compress method on the BitMap object to write image to the OutputStream
bitmapImage.compress(Bitmap.CompressFormat.PNG, 100, fos);
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
return directory.getAbsolutePath();
}
我做到了,只需在你的项目文件夹中添加一个名为“.NOMEDIA”的文件,android不会在gallary中显示它,你的声音也不会在音乐应用程序中显示。只需将一个.nomedia文件添加到项目的文件夹中,您的所有声音和图片都不会显示在库中。这是一个很好的方法,可以防止它被编程完成!