简体   繁体   English

我如何访问资产文件夹?

[英]How I access asset folder?

I need to load image from assets in folder like this我需要从这样的文件夹中的资产加载图像

my folder我的文件夹

and my code just check that how i can access my folder (sorry from poor coding)我的代码只是检查我如何访问我的文件夹(对不起,编码不好)

  public Bitmap test3(){

Bitmap bitmap = null;
AssetManager assManager = null;
try {
    InputStream is = assManager.open("train/c00/Astb412_400_30_18_161.bmp");
    bitmap = BitmapFactory.decodeStream(is);
    return bitmap;
} catch (Exception e) {
    e.printStackTrace();
}

    return bitmap;
}

So, I just test debug to see but it didn't work test debug所以,我只是测试调试看看,但它没有工作测试调试

I don't know how I access file.我不知道我如何访问文件。 please help请帮忙

  • I should put my folder in res or asset which one is better?我应该把我的文件夹放在 res 或 asset 哪个更好?
  • Can I path folder by string path (I've tried it but didn't work for me)我可以按字符串路径路径文件夹吗(我试过但对我不起作用)

Better and most suitable way is to put your asset in res folder.更好和最合适的方法是将您的资产放在 res 文件夹中。 After that you can assess them like this.之后,您可以像这样评估它们。

 Drawable image = getResources().getDrawable(R.drawable.your_file_name_goes_here);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM