开发者

Changing directory permissions

开发者 https://www.devze.com 2023-02-19 01:40 出处:网络
I need to get write permissions to the lib directory of my application (i.e. /data/data/com.my.app/lib/) and store a file there, and I need to do it from my application. Is it possible? and if so, how

I need to get write permissions to the lib directory of my application (i.e. /data/data/com.my.app/lib/) and store a file there, and I need to do it from my application. Is it possible? and if so, how?

EDIT

开发者_如何学GoBy my application I mean using Java. /data/data/com.my.app/lib/ is the path to the lib directory of the same application.

EDIT

Unfortunately, as LeffelMania said, I couldn't find any convenient way to do it. Fortunately, we solved this problem in a better way - we convinced the developers of the library to make it more dynamic :). Thanks again LeffelMania.


It is not possible to directly write into another app's file space. Your app has write access to its own space and external storage (SD card) with permission.

However, I can imagine a couple ways to do this, depending on what you're trying to do, specifically.

1) Write the file to the SD card from one app. Have the other check if it's there and read from it when it opens. Make sure to write it to your own proprietary folder - don't clog the user's storage space. If applicable to your situation, delete the file and your folders on the SD card from the other app once you've read the file.

2) Register a custom BroadcastReceiver in the recipient app, and stick the data you need to transfer inside of an Intent that you will send from the other app. You should use your own action String so that no other application in the system attempts to use your Broadcast.

0

精彩评论

暂无评论...
验证码 换一张
取 消