初始化HashMap

public static HashMap<String,String> urls = new HashMap<String,String>();
public void initMap(){
try{
db = DatabaseHelper.getInstance(CSJKActivity.this)
.getReadableDatabase();

Cursor cursor = db.query("shipin", null, null,
null, null, null, null);
Integer num = cursor.getCount();
int point = 0;
String tempname;
String tempurl;
if(num!=0)
{
cursor.moveToFirst();
while(point!=num)
{
        tempname=cursor.getString(1);
        tempurl = cursor.getString(2);
        urls.put(tempname, tempurl);
       
        cursor.moveToNext();
        point++;     
}
}
}catch (Exception e) {
            Log.e(TAG, "error: " + e.getMessage(), e);
        }
}

你可能感兴趣的:(HashMap)