我需要获取以GB(千兆字节)为单位的应用内存和内部存储空间。
我尝试过
import random
def duplicate(X, y, no_of_duplicate):
index_lst = random.sample(range(len(X)), no_of_duplicate)
y_duplicate = np.empty(no_of_duplicate)
for i, duplicate_index in enumerate(index_lst):
X.append(X[duplicate_index])
y_duplicate[i] = y[duplicate_index]
y = np.append(y, y_duplicate)
return X, y
print(len(X))
print(len(y))
X, y = duplicate(X, y, 500)
print(len(X))
print(len(y))
但未找到准确的结果,有人可以建议任何内部存储解决方案。
答案 0 :(得分:0)
在这里,尝试这个
要获取总RAM:
private long totalRamMemorySize() {
ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
ActivityManager activityManager = (ActivityManager)getSystemService(ACTIVITY_SERVICE);
activityManager.getMemoryInfo(mi);
long availableMegs = mi.totalMem / 1048576L;
return availableMegs;
}
要获得整体内部记忆力:
public static long getTotalInternalMemorySize() {
File path = Environment.getDataDirectory();
StatFs stat = new StatFs(path.getPath());
long blockSize = stat.getBlockSize();
long totalBlocks = stat.getBlockCount();
return totalBlocks * blockSize;
}
有关更多数据,请尝试使用此链接Get Device RAM and Internal Storage - Induces Smile