Reputation:
I am creating a simple Android app. To run properly, it needs the contents of a file (example.xml
) that is currently on my PC.
On creation, the app would look for the file, and then do some stuff with it.
@Override
protected void onCreate(Bundle savedInstanceState)
{
...
File file = new File("I wish I knew what to put here");
doStuffWithFile(file);
}
Unfortunately, I don't know where to put the file.
I need a location in internal storage to which both my PC and my Android app have access.
Is there such a location? If so, what file path String
would I use to access it?
Upvotes: 0
Views: 39
Reputation: 7315
You could include the file in the assets
folder of your project and then retrieve it with this.getContext().getAssets().open("example.xml")
Upvotes: 0
Reputation: 131
You can get the Download folder by using Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)
Then you can add a filename and use this e.g. with DownloadManager
Upvotes: 1