2016-03-04 80 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()