我的资源中的 raw 文件夹中有一个视频文件。我想找到文件的大小。 我有这段代码:
Uri filePath = Uri.parse("android.resource://com.android.FileTransfer/" + R.raw.video);
File videoFile = new File(filePath.getPath());
Log.v("LOG", "FILE SIZE "+videoFile.length());
但它总是给我大小为 0。我做错了什么?
最佳答案
试试这个:
AssetFileDescriptor sampleFD = getResources().openRawResourceFd(R.raw.video);
long size = sampleFD.getLength()
关于android - 获取Android文件资源的大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6049926/