Hello Everyone,
I am trying to override the openFile function of a contentProvider so
that I can use the URI in the loadURL function. The following code is
really spread on the forum but nobody seems to meet any problems on
this line File file = new File(...).
As far as I am concerned, I got a FileNotFoundException and I really
dont understand why!
If anyone has an idea that would be great.
Thanks in advance
Polo
private static final String file_path = "file:///data/data/
com.android.orange.myApp/files";
private static final String file_name = "HtmlView";
@Override
public ParcelFileDescriptor openFile(Uri uri, String mode)
{
try
{
mDbH.open();
// content that I want to add in my file
Cursor c = mDbH.fetchContent();
String content = c.getString(c.getColumnIndex
(DbAdapter.KEY_WEBVIEW_CONTENT));
c.close();
mDbH.close();
//
File file = new File(file_path,file_name);
FileWriter out;
out = new FileWriter(file);
out.write(" ");
out.close();
}
catch (FileNotFoundException ex)
{
// Checked for file existance already, so this should
not happen
return null;
}
catch (IOException ex)
{
// read or close failed
return null;
}
int m = ParcelFileDescriptor.MODE_READ_ONLY;
if (mode.equalsIgnoreCase("rw"))
m = ParcelFileDescriptor.MODE_READ_WRITE;
if (file.canRead())
{
ParcelFileDescriptor pfd =
ParcelFileDescriptor.open(file, m);
}
ParcelFileDescriptor pfd = ParcelFileDescriptor.open(file, m);
return pfd;
}
catch (FileNotFoundException e)
{
}
return null;
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---