Android 将应用程序路径声明为静态常量

Android 将应用程序路径声明为静态常量,android,Android,我试图在一个单独的常量类中声明我的应用程序使用的所有常量。我想声明应用程序路径,但不知道如何以静态方式进行声明 如何将“this”替换为可以让我获得路径的内容 public static final String DL_PATH = this.getApplicationContext().getFilesDir().getAbsolutePath() + "/"; 如何将“this”替换为可以让我获得路径的内容 public static final String DL_PATH = thi

我试图在一个单独的常量类中声明我的应用程序使用的所有常量。我想声明应用程序路径,但不知道如何以静态方式进行声明

如何将“this”替换为可以让我获得路径的内容

public static final String DL_PATH = this.getApplicationContext().getFilesDir().getAbsolutePath() + "/";
如何将“this”替换为可以让我获得路径的内容

public static final String DL_PATH = this.getApplicationContext().getFilesDir().getAbsolutePath() + "/";
你没有。没有任何东西可以用于此

欢迎您从自定义
应用程序的
onCreate()
将值分配给
DL\u PATH
。或者,完全删除
DL\u路径
,根据需要从各种组件(例如,
活动
服务
)中调用
getFilesDir()