Hunt
Hunt

Reputation: 8435

storing existing file into internal memory and get path

I have one xml file which i want to store it in a internal memory and later one i just need a path to that file to access it.

I have an existing file so there is no need to write a file inside my program i just want to store it in such a way that user accidently can not delete that file and the application can read it by accessing its path.

Note: I am using third party library which accepts file path only. i dont want to store it in SD Card

I tried AssetManager assetManager = getAssets(); but this doesn't give relative path when required. I tried /data/data/com.bcl/external.provider and copy my external.provider file in application package but didnt work.

so how to get a path where i can store file and get its path.

Upvotes: 1

Views: 4365

Answers (1)

Lalit Poptani
Lalit Poptani

Reputation: 67296

What you can do is write the file inside the files folder in data/data/package_name/ and read it from there. This folder is in internal storage so user won't be able to read the file. You can get the path using getFilesDir() which will give you as data/data/package_name/files/

Upvotes: 2

Related Questions