私たちは、内部メモリにデータを表示しないという問題を抱えているアプリケーションを開発しています。私のアプリケーションは内部メモリにデータを表示しません
私たちは実際には、エラーがメソッドのshowとarrayの内部にあると思っていますが、どこでそれを理解することはできません。この問題を解決するお手伝いができれば幸いです。
ここにlogcatがあります。
と我々のコード
public class DBActivity extends AppCompatActivity {
TextView name1 , surname1 , idnumber1;
@Override
protected void onCreate(Bundle saveInstanceState){
super.onCreate(saveInstanceState);
setContentView(R.layout.activity_db);
name1 = (TextView)findViewById(R.id.name);
surname1 = (TextView)findViewById(R.id.surname);
idnumber1 = (TextView)findViewById(R.id.idnumber);
}
public void show(View view){
try {
FileInputStream fileInputStream = openFileInput("Rank It Up.txt");
int read = -1;
StringBuffer buffer = new StringBuffer();
while ((read=fileInputStream.read()) != -1)
{
buffer.append((char) read);
}
Log.d("Rank It Up",buffer.toString());
String m = buffer.toString();
String[] data = m.split(" ");
String name2 = data[0];
String surname2 = data[1];
String idnumber2 = data[2];
name1.setText(name2);
surname1.setText(surname2);
idnumber1.setText(idnumber2);
} catch (FileNotFoundException e) {
Toast.makeText(this, "File Not Found", Toast.LENGTH_LONG).show();
} catch (IOException e){
e.printStackTrace();
}
Toast.makeText(this, "Data found", Toast.LENGTH_LONG).show();
}
public void back(View view){
Toast.makeText(this, "Main page",Toast.LENGTH_LONG).show();
Intent intent = new Intent(this, profile.class);
startActivity(intent);
}
}
誰が 'show 'メソッドを呼び出しますか? – selbie
showメソッドは、ユーザによって呼び出されます。 – RankItUpProject
また、FileNotFoundExceptionまたはIOExceptionがキャッチされても、「データが見つかりました」トーストが表示されます。 – selbie