2016-03-04 21 views
1

我試圖編寫一個將圖像保存在磁盤上的類。Android - getFilesDir()不工作(在Android Studio中爲紅色)

內部類我有方法public static String saveToSdCard(Bitmap bitmap, String filename)並在其中我試圖通過使用File path = new File(getFilesDir(), "myfolder");來獲取文件夾的引用,但我不能因爲IDE標記爲紅色。

我在做什麼錯?

+0

請先閱讀http://developer.android.com/intl/es/training/basics/data-storage/files.html! – manolodewiner

回答

0

你必須在上下文中調用它。 確保您處於活動狀態,或以其他方式在上下文實例上調用它,如getActivity().getFilesDir()context.getFilesDir()或甚至view.getContext().getFilesDir()