将列表视图项写入内部存储

时间:2019-03-02 20:47:29

标签: java android

我正在使用一个应用程序查找SSID并使用listView显示它们。有没有办法将listView中找到的数据写入手机的内部存储中?

private void scanWifi() {
    arrayList.clear();
    registerReceiver(wifiReceiver, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
    wifiManager.startScan();

    Toast.makeText(this, "Scanning WiFi ...", Toast.LENGTH_SHORT).show();
}

BroadcastReceiver wifiReceiver = new BroadcastReceiver() {

    @Override
    public void onReceive(Context context, Intent intent) {
        results = wifiManager.getScanResults();
        unregisterReceiver(this);

        for (ScanResult scanResult : results) {
            arrayList.add(scanResult.SSID + " - " + scanResult.capabilities);
            adapter.notifyDataSetChanged();
        }
    }
};

具有用于程序的所有权限的清单页面

    <uses-permission
    android:required="true"
    android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission
     android:required="true"
    android:name="android.permission.ACCESS_WIFI_STATE"/>
     <uses-permission
    android:required="true"
    android:name="android.permission.CHANGE_WIFI_STATE"/>
    <uses-permission
    android:required="true"
    android:name="android.permission.INTERNET"/>
    <uses-permission
    android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission
    android:name="android.permission.READ_EXTERNAL_STORAGE" />

0 个答案:

没有答案