Exemplo n.º 1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.book_main);

    if (SQLHelper.GetAllBooks(this).size() <= 0) {
      //	InitDatabase();
      SQLHelper.CreateOneBook(
          this,
          "Beginning Android",
          "Mark Murphy",
          "1",
          "bookImage",
          "description",
          "1",
          "East",
          "2",
          "874512",
          "nfccode1");
      SQLHelper.CreateOneBook(
          this,
          "Android for Dummies",
          "Dan Gookin",
          "1",
          "bookImage",
          "description",
          "2",
          "West",
          "15",
          "12554",
          "nfccode2");
      SQLHelper.CreateOneBook(
          this,
          "Programming Android",
          "Laird Dornin",
          "2",
          "bookImage",
          "description",
          "3",
          "North",
          "5",
          "65155",
          "nfccode3");

      SQLHelper.CreateCategory(this, "Academic");
      SQLHelper.CreateCategory(this, "Novel");
    }

    // SQLHelper.clearDatabase(this);

    // SQLHelper.clearDatabase(getApplicationContext());
    nfcAdapter = NfcAdapter.getDefaultAdapter(this);

    // Create the Pending Intent.
    int requestCode = 0;
    int flags = 0;

    Intent nfcIntent = new Intent(this, getClass());
    nfcIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);

    nfcPendingIntent = PendingIntent.getActivity(this, requestCode, nfcIntent, flags);

    String action = getIntent().getAction();
    if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) {
      try {
        processIntent(getIntent());
      } catch (UnsupportedEncodingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
  }
Exemplo n.º 2
0
  public void InitDatabase() {
    SQLHelper.CreateCategory(getApplicationContext(), list1);
    SQLHelper.CreateCategory(getApplicationContext(), list2);
    SQLHelper.CreateCategory(getApplicationContext(), list3); // create list

    for (int i = 0; i < SQLHelper.GetCategories(getApplicationContext()).size(); i++) {
      Log.d(
          "ID>>>>>>", "" + SQLHelper.GetCategories(getApplicationContext()).get(i).getCategoryID());
      SQLHelper.CreateOneBook(
          getApplicationContext(),
          "testbook" + i + "",
          "author",
          "version",
          "bookImage",
          "description",
          "level",
          "section",
          "shelve",
          "bookNumber",
          "nfcReferencecode" + i + "");

      SQLHelper.CreateOneBook(
          getApplicationContext(),
          "testbook" + i + 1 + "",
          "author",
          "version",
          "bookImage",
          "description",
          "level",
          "section",
          "shelve",
          "bookNumber",
          "nfcReferencecode" + i + 1 + "");

      SQLHelper.SaveBook(
          getApplicationContext(),
          SQLHelper.GetCategories(getApplicationContext()).get(i).getCategoryID(),
          SQLHelper.GetOneBookByNFC(getApplicationContext(), "nfcReferencecode" + i + "")
              .getBookID());

      SQLHelper.SaveBook(
          getApplicationContext(),
          SQLHelper.GetCategories(getApplicationContext()).get(i).getCategoryID(),
          SQLHelper.GetOneBookByNFC(getApplicationContext(), "nfcReferencecode" + i + 1 + "")
              .getBookID());
    }
  }