We are about to switch to a new forum software. Until then we have removed the registration on this forum.
can anyone please counsel me on how to store and reuse data on an android device ??
I use this code to check for/create an SD card directory:
String dirName; dirName = "//sdcard//folderName/"; try { File newFile = new File(dirName); if (newFile.exists()) { println("Directory already exists"); } else { newFile.mkdirs(); if (newFile.exists() && newFile.isDirectory()) { println("Directory created successfully..."); } } } catch(Exception e) { println("Error creating folder... "); }
....and this to write files (ready prepared byte array e.g myArray of data):
String fileName: fileName = "myFile"; try { saveBytes(dirName+fileName, myArray); println(fileName + " was saved to " + dirName); } catch(Exception e) { println("error while trying to save " + fileName); }
... and this to load it:
try{ loadArray=loadBytes("//sdcard//folderName/"+ fileName); } catch{ println("error while trying to load " + fileName); }
Mark
Answers
I use this code to check for/create an SD card directory:
....and this to write files (ready prepared byte array e.g myArray of data):
... and this to load it:
Mark