filesystems - how to create a persistent text file on Android hard drive and not on SD card -


after reading 7 years of questions how unique device id , android device(and how 1 should rethink not that), think creating file on device(not on sd card , not wiped during uninstall or user wipe data) approche.

but how save file , possible?

i have code save app internal storage dir only

public synchronized static string applicationid() {     if (sid == null) {         file file = new file(application.getinstance().getfilesdir(), application.getinstance().getstring(r.string.application_id_key));         try {             if (!file.exists())                 writeapplicationidfile(file);             sid = readapplicationidfile(file);         } catch (exception e) {             throw new runtimeexception("writing applicationidfile failed",e);         }     }     return sid; } private static string readapplicationidfile(file file) throws ioexception {     randomaccessfile in = new randomaccessfile(file, "r");     byte[] bytes = new byte[(int) in.length()];     in.readfully(bytes);     in.close();     return new string(bytes); }  private static void writeapplicationidfile(file file) throws ioexception {     fileoutputstream out = new fileoutputstream(file);     out.write(uuid.randomuuid().tostring().getbytes());     out.close();     logmanager.i("writeapplicationidfile", "writing applicationidfile"); } 

might /data/local/tmp if have got root access. in common practice not goot solution mobile apps store unique id's. imho, awful.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -