peacemaker Expert Licensed User Longtime User Apr 3, 2023 #1 Hi, All There is a task to get files from another app in rooted Android 7. Reading file is tested, it's OK, if the path is known. But if i have app's package name and the target file name - how to find the file in folders of the app ? I mean, to find the exact full file path.
Hi, All There is a task to get files from another app in rooted Android 7. Reading file is tested, it's OK, if the path is known. But if i have app's package name and the target file name - how to find the file in folders of the app ? I mean, to find the exact full file path.
teddybear Well-Known Member Licensed User Apr 4, 2023 #2 Try the path File.DirInternal /data/user/0/packagename/files Upvote 0
peacemaker Expert Licensed User Longtime User Apr 4, 2023 #3 Question is not to try some, but to make an algorithm to find the path correctly, on any rooted device with various drive configurations. Upvote 0
Question is not to try some, but to make an algorithm to find the path correctly, on any rooted device with various drive configurations.
teddybear Well-Known Member Licensed User Apr 4, 2023 #4 peacemaker said: Question is not to try some, but to make an algorithm to find the path correctly, on any rooted device with various drive configurations. Click to expand... I mean that you can get your app fullpath using File.DirInternal and then replace the packagename substring of the fullpath with the packagename which you want to get file. Upvote 0
peacemaker said: Question is not to try some, but to make an algorithm to find the path correctly, on any rooted device with various drive configurations. Click to expand... I mean that you can get your app fullpath using File.DirInternal and then replace the packagename substring of the fullpath with the packagename which you want to get file.
Erel B4X founder Staff member Licensed User Longtime User Apr 4, 2023 #5 No other app can access File.DirInternal which makes its actual path irrelevant. Upvote 0
peacemaker Expert Licensed User Longtime User Apr 4, 2023 #6 Hmm, indeed: 1) my app in MEMU emulator File.DirInternal gives his own path as "/data/user/0/MYPACKAGE/files" 2) but a file explorer gives the target app as "/storage/emulated/0/Android/data/TARGETPACKAGE/files" And no folder of my app like "/storage/emulated/0/Android/data/MYPACKAGE/files" Upvote 0
Hmm, indeed: 1) my app in MEMU emulator File.DirInternal gives his own path as "/data/user/0/MYPACKAGE/files" 2) but a file explorer gives the target app as "/storage/emulated/0/Android/data/TARGETPACKAGE/files" And no folder of my app like "/storage/emulated/0/Android/data/MYPACKAGE/files"
teddybear Well-Known Member Licensed User Apr 4, 2023 #7 Erel said: No other app can access File.DirInternal which makes its actual path irrelevant. Click to expand... It is the device which has root permission Upvote 0
Erel said: No other app can access File.DirInternal which makes its actual path irrelevant. Click to expand... It is the device which has root permission
peacemaker Expert Licensed User Longtime User Apr 4, 2023 #8 peacemaker said: And no folder of my app like "/storage/emulated/0/Android/data/MYPACKAGE/files" Click to expand... This path ("/storage/emulated/0/Android/data/MYPACKAGE/files") is got by B4X: Starter.rp.GetSafeDirDefaultExternal("") Upvote 0
peacemaker said: And no folder of my app like "/storage/emulated/0/Android/data/MYPACKAGE/files" Click to expand... This path ("/storage/emulated/0/Android/data/MYPACKAGE/files") is got by B4X: Starter.rp.GetSafeDirDefaultExternal("")
teddybear Well-Known Member Licensed User Apr 4, 2023 #9 peacemaker said: Hmm, indeed: 1) my app in MEMU emulator File.DirInternal gives his own path as "/data/user/0/MYPACKAGE/files" 2) but a file explorer gives the target app as "/storage/emulated/0/Android/data/TARGETPACKAGE/files" And no folder of my app like "/storage/emulated/0/Android/data/MYPACKAGE/files" Click to expand... /storage/emulated/0/Android/data/MYPACKAGE/files is File.DIrDefaultExternal, if your phone has TF card Upvote 0
peacemaker said: Hmm, indeed: 1) my app in MEMU emulator File.DirInternal gives his own path as "/data/user/0/MYPACKAGE/files" 2) but a file explorer gives the target app as "/storage/emulated/0/Android/data/TARGETPACKAGE/files" And no folder of my app like "/storage/emulated/0/Android/data/MYPACKAGE/files" Click to expand... /storage/emulated/0/Android/data/MYPACKAGE/files is File.DIrDefaultExternal, if your phone has TF card
peacemaker Expert Licensed User Longtime User Apr 4, 2023 #10 So, this works: B4X: Dim p As String = Starter.rp.GetSafeDirDefaultExternal("").Replace(Application.PackageName, TARGETPACKAGE) Dim f As List = File.ListFiles(p) It means that 2 paths can be checked, internal and external. Last edited: Apr 4, 2023 Upvote 0
So, this works: B4X: Dim p As String = Starter.rp.GetSafeDirDefaultExternal("").Replace(Application.PackageName, TARGETPACKAGE) Dim f As List = File.ListFiles(p) It means that 2 paths can be checked, internal and external.
teddybear Well-Known Member Licensed User Apr 4, 2023 #11 peacemaker said: This path ("/storage/emulated/0/Android/data/MYPACKAGE/files") is got by B4X: Starter.rp.GetSafeDirDefaultExternal("") Click to expand... If you are not sure which dir the file is in, you can test if it is existed both of internal and external dir Upvote 0
peacemaker said: This path ("/storage/emulated/0/Android/data/MYPACKAGE/files") is got by B4X: Starter.rp.GetSafeDirDefaultExternal("") Click to expand... If you are not sure which dir the file is in, you can test if it is existed both of internal and external dir