Академический Документы
Профессиональный Документы
Культура Документы
shoppinglist;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
android.support.v7.app.ActionBar;
android.support.v7.app.ActionBarActivity;
android.content.Intent;
android.database.Cursor;
android.net.Uri;
android.os.Bundle;
android.os.Environment;
android.view.Menu;
android.view.MenuItem;
android.view.View;
android.view.View.OnClickListener;
android.view.WindowManager;
android.widget.AdapterView;
android.widget.ArrayAdapter;
android.widget.Button;
android.widget.EditText;
android.widget.Spinner;
android.widget.Toast;
android.widget.AdapterView.OnItemSelectedListener;
if(result)
Toast.makeText(EditActivity.this, "Item Edited s
uccessfully", Toast.LENGTH_SHORT).show();
else
Toast.makeText(EditActivity.this, " Item
does not exist", Toast.LENGTH_SHORT).show();
dbAdapter.close();
}
}
});
categorySpinner.setOnItemSelectedListener(new OnItemSelectedList
ener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg
1,
int position, long arg3) {
// TODO Auto-generated method stub
selectedCategoryPosition = position;
categorySelected=arg0.getItemAtPosition(position
).toString();
// Toast.makeText(AddActivity.this,
// "selected Category="+selectedCategory+" posit
ion="+position,Toast.LENGTH_SHORT).show();
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is
present.
getMenuInflater().inflate(R.menu.add, menu);
menu.findItem(R.id.action_edit).setVisible(false);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
Intent intent;
int id = item.getItemId();
if(id== android.R.id.home )
{
intent= new Intent(EditActivity.this, ViewActivity.class
);
startActivity(intent);
return true;
}
if (id == R.id.action_export_all) {
// abc="Guwahati";
DbAdapter dbAdapter = new DbAdapter(EditActivity.this);
dbAdapter.open();
Cursor cursor = dbAdapter.getAllItemsWithCategory();
generateCsvFile("all_items.csv", cursor);
dbAdapter.close();
return true;
}
if (id == R.id.action_export_essential) {
DbAdapter dbAdapter = new DbAdapter(EditActivity.this);
dbAdapter.open();
Cursor cursor = dbAdapter.getEssentialItemsWithCategory(
);
generateCsvFile("essential_items.csv", cursor);
dbAdapter.close();
return true;
}
if (id == R.id.action_export_stocked) {
} while (cursor.moveToNext());
Toast.makeText(this, "completed writer", Toast.L
ENGTH_SHORT)
.show();
}
writer.flush();
writer.close();
String filelocation = root + "/" + sFileName;
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setType("text/plain");
// set the type to 'email'
emailIntent.setType("vnd.android.cursor.dir/email");
String to[] = { "" };
emailIntent.putExtra(Intent.EXTRA_EMAIL, to);
// the attachment
Uri uri = Uri.fromFile(gpxfile);
emailIntent.putExtra(Intent.EXTRA_STREAM, uri);
// the mail subject
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
startActivity(Intent.createChooser(emailIntent, "Send em
ail..."));
// startActivity(Intent.createChooser(emailIntent ,
// "Pick an Email provider"));
Toast.makeText(this, "email successful", Toast.LENGTH_SH
ORT);
} catch (IOException e) {
e.printStackTrace();
}
}
}