-1

I have created an Android Application that should be used in different social environments (shops, airports, etc.)

Each of those wants their own profile (their own background, button colours,etc.). I recieved .bak files which hold this Profile`s, but I need to somehow include them inside the Application Folder, so that they get detected.

I cannot find the Application Folder on my Computer, when I connect my Android Device to it via USB cable (so that I can copy / paste the .bak to that folder). Can anyone help me out here?

David Kasabji
  • 1,009
  • 1
  • 15
  • 31
  • you mean Android's private folder for your app? – rupps Dec 05 '14 at 13:05
  • I assume, yes. Or ANY way really, just to put those `bak`files inside my App, so when the App gets started it loads that Profile. – David Kasabji Dec 05 '14 at 13:10
  • not sure what you trying to do, if you need the private dir where your app can load / store files, take a look at http://stackoverflow.com/questions/4739374/android-get-applications-home-data-directory – rupps Dec 05 '14 at 13:15

1 Answers1

0

You can access your app folder like this

getContext().getExternalFilesDir(null).getAbsolutePath()

For using permissions WRITE_EXTERNAL_STORAGE and/or READ_EXTERNAL_STORAGE are required. And for first-time application launch is not better to put your .bak file with profiles to assets, and when apk will start first time copy to app-folder in background? Usually app-folder have path like "sdcard/Android/data/your_app_package_name/files" but if u did not write something to this folder, folder will not be created.

doubledeath
  • 205
  • 1
  • 11
  • So with that, I can access a file that was pasted inside "MyProject" ? – David Kasabji Dec 05 '14 at 13:24
  • Inside your project you can put this file into assets folder. When your app will start first time you can copy this file to app-folder (getContext().getExternalFilesDir(null).getAbsolutePath()) and after your can work with local copy of this file on device. If you want to get local copy of file on device you can find it in "sdcard/Android/data/yourproject_package_name". – doubledeath Dec 05 '14 at 13:36
  • Argh, the thing is, I dont have an SD card on the tablet... Any other way to do this ? – David Kasabji Dec 05 '14 at 13:41
  • So you can do the same way but just use Environment.getExternalStorageDirectory().getAbsolutePath() instead of getContext().getExternalFilesDir(null).getAbsolutePath() – doubledeath Dec 05 '14 at 13:52
  • And this will automaticly give the path to the File that I copy / pasted inside my project ? I didnt put it in assets (the .bak file), should I put it there, so that my App see's it with the above code? – David Kasabji Dec 05 '14 at 13:57
  • yes then you can get it from your code like context.getResources().getAssets() and pass to stream, for example something like this "new BufferedReader( new InputStreamReader(getAssets().open("filename.txt")));" and get file from this stream – doubledeath Dec 05 '14 at 14:02
  • Done. Accepted your answer. Thanks! – David Kasabji Dec 05 '14 at 14:19