简体   繁体   中英

C++ read internal file Android NDK

There is a file located in /data/user/0/com.uniquestudio.android.iemoji/files/yibaiwan.txt .

I want to read the file in JNI.

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

However in.good() is always false . What's wrong?

Can anyone help me? Thanks in advance.

EDIT for permission

As you know, INTERNAL_STORAGE does not require permission.

EDIT for file info

The file is encrypted file. When I use above code to read normal file, everything works well. Now I want to read the encrypted file then decrypt it.

If anyone meets same issue, you maybe create file as root role. If you edit file or create file under root , you can not visit it anymore with normal user role.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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