I am running my android app on the Blackberry Playbook using RIM's eclipse plugin.
Files I create in the "/accounts/1000/shared/documents" directory are "locked" (when I browse to them and try open using the AIR browser, I get the error message "file locked"). Files that I create in the "/sdcard" directory (the one returned by Environment.getExternalStorage) work fine. I can create and read these files programatically using the below code.
Any suggestions on how to create files in the documents directory which are not "locked"?
public class TempActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
try
{
File docFile = new File("/accounts/1000/shared/documents/tmp.txt");
File sdcardFile = new File(Environment.getExternalStorageDirectory().getPath() + "/tmp.txt");
FileWriter writer = new FileWriter(docFile);
try
{
writer.write("Hello doc file");
Log.i("success writing doc file", "success writing doc file");
}
catch (Exception e)
{
Log.e("exception writing doc file", Log.getStackTraceString(e));
}
writer.close();
writer = new FileWriter(sdcardFile);
try
{
writer.write("Hello sdcard file");
Log.i("success writing sdcard file", "success writing sdcard file");
}
catch (Exception e)
{
Log.e("exception writing sdcard file", Log.getStackTraceString(e));
}
writer.close();
FileReader in = new FileReader(docFile);
BufferedReader reader = new BufferedReader(in);
try
{
Log.i("firstLine in doc file", reader.readLine());
}
catch (Exception e)
{
Log.e("exception reading doc file", Log.getStackTraceString(e));
}
in.close();
reader.close();
in = new FileReader(sdcardFile);
reader = new BufferedReader(in);
try
{
Log.i("firstLine in sdcard file", reader.readLine());
}
catch (Exception e)
{
Log.e("exception reading sdcard file", Log.getStackTraceString(e));
}
in.close();
reader.close();
}
catch (Exception e)
{
Log.e("exception", Log.getStackTraceString(e));
}
}
}
Take a look at this thread regarding files on the Playbook and Android.