-
Java Grundkurs
Soll mir fürs erste die CID der SD Card liefern ,
zuerst wird der CPU Typ bestimmt und dementsprechend dann die Abfrage gestartet
funktioniert einzeln auch schon aber alles zusammen da Bekomme ich nur einen Programmabsturz
Kann mir bette jemand bei meinen Vorhaben helfen ich habe arge Probleme mit den Java Klasssen
Optimieren lässt sich das ganze sicher auch noch
(der Code ist sonst eig besser Formatiert)
Abfrage
Code:
public
class Main extends Activity {
// private SysUtils Syst;
private SdCard Sd;
@Override
publicvoid onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.
main);
// Syst = new SysUtils();
Sd = new SdCard();
findViewById(R.id.
btnToast).setOnClickListener(new Button.OnClickListener()
{
public
void onClick(View v) {
try
{
Toast.makeText(getApplicationContext(),
"SID of MMC = " + Sd.ReadsdCID(), Toast.LENGTH_LONG).show();
}
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} }
);
}
}
SdCard.java
Code:
public
class SdCard {
private SysUtils Syst;
String
Omap = ("/sys/devices/platform/mmci-omap-hs.0/mmc_host/mmc0/mmc0:aaaa/cid");
String
MSM = ("/sys/devices/platform/msm_sdcc.1/mmc_host/mmc0/mmc0:****/cid");
public String ReadsdCID() throws IOException {
String sd_cid =
"";
if (Syst.ifQualComm()) {
try {
BufferedReader input =
new BufferedReader(new FileReader(MSM));
sd_cid = input.readLine();}
catch (FileNotFoundException e) {
// Toast.makeText(Con,e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
}
}
if (Syst.ifOmap()) {
try {
BufferedReader input =
new BufferedReader(new FileReader(Omap));
sd_cid = input.readLine();}
catch (FileNotFoundException e) {
// Toast.makeText(Con,e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
}
}
return sd_cid;
}
}
SysUtils.java
Code:
public Boolean ifQualComm() {
File theDir =
new File("/sys/devices/platform/msm_sdcc.1");
if (theDir.exists()){
returntrue;
}
returnfalse;
}
public Boolean ifOmap() {
File theDir =
new File("/sys/devices/platform/mmci-omap-hs.0");
if (theDir.exists()){
returntrue;
}
returnfalse;
}
}