I got an app on which you can put your signature. I'm having trouble with saving the image. I would expect the file to be saved in sdcard/signature, because thats the folder i specified in strings.xml and the folder is created. But instead it saved the image to the DCIM/camera folder and not in the sdcard/signature folder.
I already read about deleting the image from the DCIM folder, so thats not a problem. But i would really appriciate if someone can tell me why the image is not saving in sd/signature
In onCreate this happens (external dir is just a name like StoreSignature for a folder to store the images):
tempDir = Environment.getExternalStorageDirectory() + "/" + getResources().getString(R.string.external_dir) + "/";
ContextWrapper cw = new ContextWrapper(getApplicationContext());
File directory = cw.getDir(getResources().getString(R.string.external_dir), Context.MODE_PRIVATE);
This is the save method:
mGetSign.setOnClickListener(new OnClickListener()
{
public void onClick(View v)
{
Log.v("log_tag", "Panel Saved");
boolean error = captureSignature();
if(!error){
mView.setDrawingCacheEnabled(true);
mSignature.save(mView);
Bundle b = new Bundle();
String status = "done";
File path = mypath;
Log.i("info4", path.toString());
String[] arr={status, path.toString()};
b.putStringArray("status", arr);
Log.i("info5", arr.toString());
Intent intent = new Intent();
intent.putExtras(b);
setResult(RESULT_OK,intent);
finish();
}
}
});
finally this is where the folders are prepared (dont know if this had to do with is)
private boolean prepareDirectory()
{
try
{
if (makedirs())
{
return true;
} else {
return false;
}
} catch (Exception e)
{
e.printStackTrace();
Toast.makeText(this, "Kan het file systeem niet vinden.. Zit de SD-kaart er goed in?", 1000).show();
return false;
}
}
/**
* Creates a directory
*
* @return whether the directory is created or not
*/
private boolean makedirs()
{
File tempdir = new File(tempDir);
if (!tempdir.exists())
tempdir.mkdirs();
if (tempdir.isDirectory())
{
File[] files = tempdir.listFiles();
for (File file : files)
{
if (!file.delete())
{
System.out.println("Deleten is mislukt " + file);
}
}
}
return (tempdir.isDirectory());
}
Strings.xml (signature values)
<string name="cancel">Annuleren</string>
<string name="clear">Opnieuw</string>
<string name="save">Opslaan</string>
<string name="naam">Naam</string>
<string name="external_dir">Handtekening</string>
<string name="input"></string>
<string name="title_activity_signature">Handtekening</string>
Is there anyone who sees what i'm doing wrong?
Thanks in advance!