ユーザ用ツール

サイト用ツール

サイドバー

About

Contents

Materials Link

その他

PR


wiki:android:tips:008

008 本体SDカードのパスを取得する

概要

NDKを利用してネイティブコードから本体SDカードのパスを取得します。

Cのコード

static string GetInternalDataPath()
{
	jclass cls_Env = env->FindClass( "android/app/NativeActivity" );
 
	jmethodID mid_getExtStorage = env->GetMethodID( cls_Env, "getFilesDir","()Ljava/io/File;" );
	jobject obj_File = env->CallObjectMethod( g_androidApp->activity->clazz, mid_getExtStorage );
	jclass cls_File = env->FindClass( "java/io/File" );
 
	jmethodID mid_getPath = env->GetMethodID( cls_File, "getPath", "()Ljava/lang/String;" );
	jstring obj_Path = (jstring)env->CallObjectMethod(obj_File, mid_getPath);
 
	const char* path = env->GetStringUTFChars(obj_Path, NULL);
	eaPath = path;
	env->ReleaseStringUTFChars(obj_Path, path);
 
	return eaPath;
}
Permalink wiki/android/tips/008.txt · 最終更新: 2014/11/06 09:09 (外部編集)

oeffentlich