質問編集履歴

5

コードの追加

2017/04/02 15:28

投稿

edoooooo
edoooooo

スコア476

test CHANGED
File without changes
test CHANGED
@@ -7,6 +7,66 @@
7
7
  どうぞアドバイスの方をよろしくお願いいたします。
8
8
 
9
9
 
10
+
11
+ ファイル読み込みのコードです。
12
+
13
+ ```java
14
+
15
+ // タイトル、内容が空白の場合、保存しない
16
+
17
+ if (title.isEmpty() || content.isEmpty()) {
18
+
19
+ Toast.makeText(this, R.string.msg_destruction, Toast.LENGTH_SHORT).show();
20
+
21
+ }else {
22
+
23
+
24
+
25
+
26
+
27
+ // 保存
28
+
29
+ OutputStream out = null;
30
+
31
+ PrintWriter writer = null;
32
+
33
+ try {
34
+
35
+ out = this.openFileOutput(mFileName, Context.MODE_PRIVATE);
36
+
37
+ writer = new PrintWriter(new OutputStreamWriter(out, "UTF-8"));
38
+
39
+ // タイトル書き込み
40
+
41
+ writer.println(title);
42
+
43
+ // 内容書き込み
44
+
45
+ writer.println(content);
46
+
47
+
48
+
49
+ //・・・・・実行日書き込み
50
+
51
+ writer.println(data);
52
+
53
+
54
+
55
+
56
+
57
+ writer.close();
58
+
59
+ out.close();
60
+
61
+
62
+
63
+ //保存に成功しました。
64
+
65
+ Toast.makeText(this, R.string.msg_upd, Toast.LENGTH_SHORT).show();
66
+
67
+
68
+
69
+ ```
10
70
 
11
71
  ```java
12
72
 

4

がぞう

2017/04/02 15:28

投稿

edoooooo
edoooooo

スコア476

test CHANGED
File without changes
test CHANGED
File without changes

3

画像の追加

2017/04/02 14:51

投稿

edoooooo
edoooooo

スコア476

test CHANGED
File without changes
test CHANGED
@@ -71,3 +71,7 @@
71
71
  mList.add(map);
72
72
 
73
73
  ```
74
+
75
+
76
+
77
+ ![イメージ説明](edf2fea25a280b56e0195fb50df7641f.png)

2

data

2017/04/02 14:42

投稿

edoooooo
edoooooo

スコア476

test CHANGED
File without changes
test CHANGED
@@ -34,6 +34,8 @@
34
34
 
35
35
 
36
36
 
37
+ //data=
38
+
37
39
  //ここでdataへ日付を読み込みたいのですが、2行目以降と指定しているため、
38
40
 
39
41
  //内容(content)と日付(data)が全て、内容の欄に表示されてしまいます。

1

コードの追加

2017/04/02 13:59

投稿

edoooooo
edoooooo

スコア476

test CHANGED
File without changes
test CHANGED
@@ -46,4 +46,26 @@
46
46
 
47
47
  in.close();
48
48
 
49
+ } catch (Exception e) {
50
+
51
+ Toast.makeText(this, "error", Toast.LENGTH_LONG).show();
52
+
53
+ }
54
+
55
+
56
+
57
+ // ListView用のアダプタにデータをセット
58
+
59
+ Map<String, String> map = new HashMap<String, String>();
60
+
61
+ map.put("filename", fileName);
62
+
63
+ map.put("title", title);
64
+
65
+ map.put("content", content);
66
+
67
+ //map.put("data",data);
68
+
69
+ mList.add(map);
70
+
49
71
  ```