Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There is no way to password protect a .csv file, in Android or any other platform. .CSV files are plain text and any form of password protection would make them another format altogether and they would become unreadable in any other software.</p> <p>Your best bet would probably be to try to output to a proprietary file format (for example, .xls) and use the password protection provided there.</p> <p>This has other problems in that you will need to locate the necessary libraries to produce that file type, and you may need to be licensed to create those files. Plus, the password protection on files is notoriously weak so you cannot guarantee that the password would prevent anybody from reading the contents.</p> <p>So, in short - you cannot do what you want with .csv files.</p> <hr> <p>EDIT:</p> <p><a href="https://stackoverflow.com/questions/4275311/how-to-encrypt-and-decrypt-file-in-android">How to encrypt and decrypt file in Android?</a> seems to have a couple of examples on how to encrypt/decrypt files in Android, though the question is - will you need to share this file with other systems?</p> <p>Your question isn't clear on this point but if you do not, then just use <a href="http://developer.android.com/reference/android/content/Context.html#getExternalFilesDir(java.lang.String)" rel="nofollow noreferrer">getExternalFilesDir()</a> for an encrypted location on the external SD card, or <a href="http://developer.android.com/reference/android/content/Context.html#getFilesDir()" rel="nofollow noreferrer">getFilesDir()</a> for your private file location on the internal memory, which would both serve to limit access to the file to just your application.</p> <p>The benefit of using the above functions is that you do not need to do anything special to access the file - just open and read/write it as you would any other file.</p> <p>If you did need to share the file, a simple export function could be written.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload