It is not actually good practice to avoid any paths, since the Android Gradle build system requires you to place all assets under the asset folder, for the sake of proper organization.
But in case you really want to avoid using an absolute path, you can either go with makata's answer, or you can do this -
Open your project's root directory. Let us say your project name is MyAndroidProject
.
Check out the file MyAndroidProject.iml
.
Within the <configuration>
tag, you should see
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
.
In case you don't see any such option, go to /MyAndroidProject/app/
and open app.iml.
- Change
/src/main/assets
to /src/main/java/com/mypackage/subpackage/myandroidproject
.
Now you can place all your assets within the package of your application, and all files will be read from there as you wanted. But then you'll be messing around with files you don't really want to mess with, and that can lead to problems IMO.