Libraryless. Click here for Pure Java version (1079L/8K/26K).
!747 m { static long nextID = 5000000; static new Map<S, S> titles; static new Map<S, S> texts; static new Map<S, File> images; p { readLocally("nextID titles texts images"); //print("New ID: " + newID()); print("Next ID is at: " + nextID); makeAndroid("This is the local storage android.", stringfunc { answer(s) }); } static synchronized S answer(S s) ctex { new Matches m; if (match3("can you store snippets", s)) return "yes"; if (match3("what is the next snippet ID", s)) return "#" + nextID; if (match3("what do you store on", s)) return "file system (local)"; if (match3("please create a new snippet id", s)) return newID(); if (match3("please set title for snippet * to *", s, m)) { titles.put(formatSnippetID(m.m[0]), m.m[1]); saveLocally("titles"); return "ok"; } if (match3("please set text for snippet * to *", s, m)) { texts.put(formatSnippetID(m.m[0]), m.m[1]); saveLocally("texts"); return "ok"; } if (match3("please load image for snippet * from *", s, m)) { byte[] data = loadBinaryPage(m.m[1]); File file = new File(programDir(), "images/" + formatSnippetID(m.m[0])); saveBinaryFile(file, data); images.put(formatSnippetID(m.m[0]), file); saveLocally("images"); return "ok - " + data.length + " bytes loaded and saved"; } if (match3("what is the title of snippet *?", s, m)) return titles.get(formatSnippetID(m.m[0])); if (match3("what is the text of snippet *?", s, m)) return texts.get(formatSnippetID(m.m[0])); if (match3("where is the image of snippet *?", s, m)) { File f = images.get(formatSnippetID(m.m[0])); return f != null ? f.getAbsolutePath() : "There is no image there."; } return "lalala"; } static synchronized S newID() { S id = "#" + nextID++; saveLocally("nextID"); return id; } }
download show line numbers debug dex old transpilations
Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, jtubtzbbkimh, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1001109 |
Snippet name: | Local storage android (texts + images) |
Eternal ID of this version: | #1001109/1 |
Text MD5: | ea7e845b4dcebb9ad1ba402a34b98bff |
Transpilation MD5: | cd47c522eb4c32d9ed1af74520377a9c |
Author: | stefan |
Category: | javax |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-09-22 15:43:05 |
Source code size: | 2039 bytes / 64 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 666 / 714 |
Referenced in: | #3000382 - Answer for ferdie (>> t = 1, f = 0) #3000383 - Answer for funkoverflow (>> t=1, f=0 okay) |