简体   繁体   English

C ++读取内部文件Android NDK

[英]C++ read internal file Android NDK

There is a file located in /data/user/0/com.uniquestudio.android.iemoji/files/yibaiwan.txt . /data/user/0/com.uniquestudio.android.iemoji/files/yibaiwan.txt有一个文件。

I want to read the file in JNI. 我想在JNI中读取文件。

ifstream in.open(in_file_name, ios::binary);
LOGD("%d", in.good() ? 1 : 0);

However in.good() is always false . 但是in.good()始终为false What's wrong? 怎么了?

Can anyone help me? 谁能帮我? Thanks in advance. 提前致谢。

EDIT for permission 编辑许可

As you know, INTERNAL_STORAGE does not require permission. 如您所知,INTERNAL_STORAGE不需要许可。

EDIT for file info 编辑文件信息

The file is encrypted file. 该文件是encrypted文件。 When I use above code to read normal file, everything works well. 当我使用上述代码读取普通文件时,一切正常。 Now I want to read the encrypted file then decrypt it. 现在,我想读取encrypted文件然后decrypt

If anyone meets same issue, you maybe create file as root role. 如果有人遇到相同的问题,则可以将文件创建为root角色。 If you edit file or create file under root , you can not visit it anymore with normal user role. 如果您在root下编辑文件或创建文件,则无法再以普通用户身份访问该文件。

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

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