1

I'm new to Android. I searched for how to create a file within the Android directory and was lead to this post which mentions to save it to the assets directory: Where to put text files in directory in Android

My problem is, turns out I cannot edit files which are in the assets directory.

context.openFileOutput saves it to what context.getFilesDir() returns, which is /data/ folder (which from my understanding is not within the Project directory because I need to ask permission for it) but the problem I'm having with saving it there is that I get permission denied, even when I have permission to save (I made this post about it: Getting a Permission denied error when creating a file with Android, even when permission is given)

With that said, what's the correct way to save a .txt file within the Android project directory but Not inside the assets folder?

Community
  • 1
  • 1
SilentDev
  • 20,997
  • 28
  • 111
  • 214

1 Answers1

0

You can't do that. The "project directory" (this is basically the content of your APK that is installed on the device) is read-only. Android provides you with a number of places where you can write data:

  • application-specific private data directory
  • Shared preferences
  • external storage (SD-card or similar)
  • SQLite database
David Wasser
  • 93,459
  • 16
  • 209
  • 274