1

I made an app that i'm am working on updates for and in the old version I hard coded the file path like this

"/data/data/my.app.here/troll"

so now I am trying to do an update and I am trying to use something similar to

Context.getFilesDir()

but that returns

/data/user/0/my.app.here/files

the app info is stored on the troll file and when I push updates I don't want to use another path and have them start their information all over again. What's the best way to resolve this situation?

James Z
  • 12,209
  • 10
  • 24
  • 44
JRowan
  • 6,824
  • 8
  • 40
  • 59
  • 1
    As I understand `/data/user/` is just a symlink of `/data/data`, so technically it should point to the same path. Do you manage to find your file in `/user/0/your.app/`? – Suleyman May 22 '18 at 00:44
  • I cant even find that directory and i tried changing it how i have above and its 2 different files – JRowan May 22 '18 at 01:10

1 Answers1

2

Can someone kindly tell me the best way to resolve this situation?

Call getParentFile() on the File returned by getFilesDir() to get its parent directory. Your troll file should be in there. That wasn't a great place to put a file, and so YMMV.

If your concern is the /data/user/0/, that will be handled by Android and should map to /data/data/ when the primary user is the one running your app.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • works perfectly, thanks for the info, now I know for next time. Im just working on my own stuff im a senior in college I plan to really make a living from this. this isn't the first time you helped me thanks a lot. – JRowan May 22 '18 at 01:32