写Androidstudio 时,定义一个SaveInfo类,提示“class 'SaveInfo' is never used”,
class Saveinfo 里的方法 SaveInformation‘’,提示“Method 'SaveInformation' is never used”
class Saveinfo 里的方法‘getSaveInformation’, 提示“Method 'getSaveInformation' is never used”
所以在其它.jave文件里引用这两个方法的时候,提示‘can't resovle method SaveInformation/getSaveInformation in 'SaveInfo'’
SaveInfo .java
package com.example.myapplication9;
import android.content.Context;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
public class SaveInfo {
public static boolean SaveInformation(Context context, String username, String password, String password2, String mail) {
try {
FileOutputStream fos = context.openFileOutput("data.txt", Context.MODE_APPEND);
fos.write(("用户名:" + username + " 密码:" + password + "邮箱:" + mail).getBytes());
fos.close();
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
public static Map<String, String> getSaveInformation(Context context) {
try {
FileInputStream fis = context.openFileInput("data.txt");
BufferedReader br = new BufferedReader(new InputStreamReader(fis));
String str = br.readLine();
String[] infos = str.split("用户名:"+"密码:"+"邮箱:");
Map<String, String> map = new HashMap<String, String>();
map.put("username", infos[0]);
map.put("password", infos[1]);
fis.close();
return map;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}
定义一个SaveInfo类,提示“class 'SaveInfo' is never used”,
class Saveinfo 里的方法 SaveInformation‘’,提示“Method 'SaveInformation' is never used”
class Saveinfo 里的方法‘getSaveInformation’, 提示“Method 'getSaveInformation' is never used”
所以在其它.jave文件里引用这两个方法的时候,提示‘can't resovle method SaveInformation/getSaveInformation in 'SaveInfo'’
百度没有答案
解决这个问题
因为这个类没有被使用过,不是报错,其他类中实例化他并且使用他就行了