Android添加列表到Hashmap替换旧列表

时间:2017-06-28 07:16:55

标签: java android hashmap

*一次又一次地调用addOption函数,替换Map

中的旧值
#!/bin/bash

echo " --- Enter the Database name ---"
read databasename

echo " --- enter the table name --- "
read table_name



sqlite3 $databasename.db "DROP TABLE IF EXISTS $table_name;"

sqlite3 $databasename.db  "CREATE TABLE IF NOT EXISTS $table_name(cus_id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,cus_name TEXT NOT NULL UNIQUE ,cus_domain TEXT UNIQUE, cus_status TEXT NOT NULL,Port INTEGER NOT NULL);"


echo " --- Enter the total number of customer records do you want ---"
read cus_count


echo "--- Enter the following details one by one---"

port_num=8080
declare -a customer

for((i=1;i<=cus_count;i++))
do

echo "enter the $i customer details"

echo "---Enter the customer name---"
read c_name


customer=$(sqlite3 $databasename.db "select cus_name from $table_name");

for cus in "${customer[@]}"
do

c_domain="$c_name"

if [[ "$c_name" != "$customer" ]]

then
    echo "---Enter the Status(Active/Inactive)---"
    read c_status

if [[ "$port_num" == "$port_num" ]]; then
       port_num=$(($port_num + 1))


sqlite3 $databasename.db "INSERT OR IGNORE INTO $table_name (cus_name,cus_domain,cus_status, Port) VALUES(\"$c_name\",\"${c_domain,,}.in\",\"$c_status\",\"$port_num\") ;"
sqlite3 $database.db ".read SQLTableTransfer"


fi

else
    echo "!!!OOPS you entered customer name already available!!!"
    echo "---Please enter new customer name---"

i=$(($i - 1))

fi
done
done

echo " --- Records from the $table_name ---"

sqlite3 $databasename.db "select * from $table_name;"

Hashmap旧值被新的视图Id值替换。

1 个答案:

答案 0 :(得分:0)

谢谢大家,我发现了答案,因为我正在使用java,所以它总是通过引用发送值,所以我修改的值在父Map中被修改,所以我创建了一个新的列表,并为每个对象,我插入了父列出子列表的对象构造函数中的值。