android - Get value from EditText into table in AWS DynamoDB -


i want put new items textbox wrote users existing table in dynamodb. however, have encountered errors dont understand. below codes:

add method

public class add_item  {      private string title;      private amazondynamodbclient client;      string tablename = "tesis_ftsm";        public void dynamodbload() throws ioexception      {          awscredentials credentials = new propertiescredentials(dynamodbclient.class.getclassloader().getresourceasstream("awscredentials.properties"));          client = new amazondynamodbclient(credentials);          client.setregion(region.getregion(regions.us_west_2));      }        public void add()          {                          final edittext title = (edittext)findviewbyid(r.id.text1);              string tajuk = title.gettext().tostring();                          map<string, attributevalue> item = new hashmap<string, attributevalue>();                try {                 item.put("id", new attributevalue().withs(tajuk));                    putitemrequest itemrequest = new putitemrequest().withtablename(                          tablename).withitem(item);                  client.putitem(itemrequest);                  item.clear();                } catch (exception e) {                  system.err.println("create items failed.");                  system.err.println(e.getmessage());              }          }

mainactivity

public class task extends asynctask<string, void, string> {            @override          protected string doinbackground(string... params) {                looper.prepare();                try              {                  add_item db = new add_item();                    db.dynamodbload();                  db.add();                                  } catch (exception e)              {                  e.printstacktrace();              }              looper.mylooper().quit();              return null;          }          protected void onpostexecute(string page)          {              //onpostexecute          }      }

logcat errors

06-15 10:33:33.938  16885-17179/com.af.ftsm.testing w/system.err﹕java.lang.nullpointerexception  06-15 10:33:33.938  16885-17179/com.af.ftsm.testing w/system.err﹕ @ android.app.activity.findviewbyid(activity.java:1957)  06-15 10:33:33.938  16885-17179/com.af.ftsm.testing w/system.err﹕ @ com.af.ftsm.testing.add_item.<init>(add_item.java:26)  06-15 10:33:33.938  16885-17179/com.af.ftsm.testing w/system.err﹕ @ com.af.ftsm.testing.mainactivity$task.doinbackground(mainactivity.java:50)  06-15 10:33:33.938  16885-17179/com.af.ftsm.testing w/system.err﹕ @ com.af.ftsm.testing.mainactivity$task.doinbackground(mainactivity.java:39)  06-15 10:33:33.938  16885-17179/com.af.ftsm.testing w/system.err﹕ @ android.os.asynctask$2.call(asynctask.java:288)  06-15 10:33:33.938  16885-17179/com.af.ftsm.testing w/system.err﹕ @ java.util.concurrent.futuretask.run(futuretask.java:237)  06-15 10:33:33.938  16885-17179/com.af.ftsm.testing w/system.err﹕ @ android.os.asynctask$serialexecutor$1.run(asynctask.java:231)  06-15 10:33:33.938  16885-17179/com.af.ftsm.testing w/system.err﹕ @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1112)  06-15 10:33:33.938  16885-17179/com.af.ftsm.testing w/system.err﹕ @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:587)  06-15 10:33:33.938  16885-17179/com.af.ftsm.testing w/system.err﹕ @ java.lang.thread.run(thread.java:841)

is method of adding items table wrong or otherwise? thank you.

based on information, believe resource r.id.text1 doesn't exist, findviewbyid returns null. type cast on null throw npe. if not, please tell on line 26 of add_item.java.

ps: you'd better avoid propertiescredentials in production level android app. cognitocachingcredentialsprovider recommended way of getting aws credentials. see amazon cognito identity more details.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -